home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / jikes-1.02 / src / error.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-26  |  135.3 KB  |  4,648 lines

  1. // $Id: error.cpp,v 1.28 1999/08/26 15:34:07 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #include "config.h"
  11. #include <sys/stat.h>
  12. #include "error.h"
  13. #include "control.h"
  14. #include "semantic.h"
  15. #include "ast.h"
  16.  
  17. unsigned char SemanticError::warning[SemanticError::_num_kinds] = { 0 };
  18. void (*SemanticError::print_message[SemanticError::_num_kinds]) (SemanticError::ErrorInfo &, LexStream *, Control &) = { NULL };
  19.  
  20. SemanticError::SemanticError(Control &control_, FileSymbol *file_symbol) : control(control_),
  21.                                                                            lex_stream(file_symbol -> lex_stream),
  22.  
  23.                                                                            buffer(1024),
  24.                                                                            error(512),
  25.                                                                            clone_count(0),
  26.                                                                            num_errors(0),
  27.                                                                            num_warnings(0)
  28. {}
  29.  
  30. //
  31. // This procedure is invoked by an JIKES PARSER or a semantic
  32. // routine to process an error message.  The JIKES parser always
  33. // passes the value 0 to msg_level to indicate an error.
  34. // This routine simply stores all necessary information about
  35. // the message into an array: error.
  36. //
  37. void SemanticError::Report(SemanticErrorKind msg_code,
  38.                            LexStream::TokenIndex left_token,
  39.                            LexStream::TokenIndex right_token,
  40.                            wchar_t *insert1,
  41.                            wchar_t *insert2,
  42.                            wchar_t *insert3,
  43.                            wchar_t *insert4,
  44.                            wchar_t *insert5,
  45.                            wchar_t *insert6,
  46.                            wchar_t *insert7,
  47.                            wchar_t *insert8,
  48.                            wchar_t *insert9)
  49. {
  50.     if (clone_count > 0) // do not report errors detected while processing a clone !!!
  51.         return;
  52.  
  53.     int i = error.NextIndex();
  54.  
  55.     if (warning[msg_code] > 0)
  56.          num_warnings++;
  57.     else num_errors++;
  58.  
  59.     error[i].msg_code = msg_code;
  60.  
  61.     int total_length = 0,
  62.         length1,
  63.         length2,
  64.         length3,
  65.         length4,
  66.         length5,
  67.         length6,
  68.         length7,
  69.         length8,
  70.         length9;
  71.  
  72.     if (insert1)
  73.     {
  74.         length1 = wcslen(insert1);
  75.         total_length += (length1 + 1);
  76.     }
  77.     else error[i].insert1 = NULL;
  78.  
  79.     if (insert2)
  80.     {
  81.         length2 = wcslen(insert2);
  82.         total_length += (length2 + 1);
  83.     }
  84.     else error[i].insert2 = NULL;
  85.  
  86.     if (insert3)
  87.     {
  88.         length3 = wcslen(insert3);
  89.         total_length += (length3 + 1);
  90.     }
  91.     else error[i].insert3 = NULL;
  92.  
  93.     if (insert4)
  94.     {
  95.         length4 = wcslen(insert4);
  96.         total_length += (length4 + 1);
  97.     }
  98.     else error[i].insert4 = NULL;
  99.  
  100.     if (insert5)
  101.     {
  102.         length5 = wcslen(insert5);
  103.         total_length += (length5 + 1);
  104.     }
  105.     else error[i].insert5 = NULL;
  106.  
  107.     if (insert6)
  108.     {
  109.         length6 = wcslen(insert6);
  110.         total_length += (length6 + 1);
  111.     }
  112.     else error[i].insert6 = NULL;
  113.  
  114.     if (insert7)
  115.     {
  116.         length7 = wcslen(insert7);
  117.         total_length += (length7 + 1);
  118.     }
  119.     else error[i].insert7 = NULL;
  120.  
  121.     if (insert8)
  122.     {
  123.         length8 = wcslen(insert8);
  124.         total_length += (length8 + 1);
  125.     }
  126.     else error[i].insert8 = NULL;
  127.  
  128.     if (insert9)
  129.     {
  130.         length9 = wcslen(insert9);
  131.         total_length += (length9 + 1);
  132.     }
  133.     else error[i].insert9 = NULL;
  134.  
  135.     if (total_length > 0)
  136.     {
  137.         wchar_t *ptr = new wchar_t[total_length];
  138.         buffer.Next() = ptr;
  139.  
  140.         if (insert1)
  141.         {
  142.             memmove(ptr, insert1, length1 * sizeof(wchar_t));
  143.             error[i].insert1 = ptr;
  144.             ptr += length1;
  145.             *ptr++ = U_NULL;
  146.         }
  147.  
  148.         if (insert2)
  149.         {
  150.             memmove(ptr, insert2, length2 * sizeof(wchar_t));
  151.             error[i].insert2 = ptr;
  152.             ptr += length2;
  153.             *ptr++ = U_NULL;
  154.         }
  155.  
  156.         if (insert3)
  157.         {
  158.             memmove(ptr, insert3, length3 * sizeof(wchar_t));
  159.             error[i].insert3 = ptr;
  160.             ptr += length3;
  161.             *ptr++ = U_NULL;
  162.         }
  163.  
  164.         if (insert4)
  165.         {
  166.             memmove(ptr, insert4, length4 * sizeof(wchar_t));
  167.             error[i].insert4 = ptr;
  168.             ptr += length4;
  169.             *ptr++ = U_NULL;
  170.         }
  171.  
  172.         if (insert5)
  173.         {
  174.             memmove(ptr, insert5, length5 * sizeof(wchar_t));
  175.             error[i].insert5 = ptr;
  176.             ptr += length5;
  177.             *ptr++ = U_NULL;
  178.         }
  179.  
  180.         if (insert6)
  181.         {
  182.             memmove(ptr, insert6, length6 * sizeof(wchar_t));
  183.             error[i].insert6 = ptr;
  184.             ptr += length6;
  185.             *ptr++ = U_NULL;
  186.         }
  187.  
  188.         if (insert7)
  189.         {
  190.             memmove(ptr, insert7, length7 * sizeof(wchar_t));
  191.             error[i].insert7 = ptr;
  192.             ptr += length7;
  193.             *ptr++ = U_NULL;
  194.         }
  195.  
  196.         if (insert8)
  197.         {
  198.             memmove(ptr, insert8, length8 * sizeof(wchar_t));
  199.             error[i].insert8 = ptr;
  200.             ptr += length8;
  201.             *ptr++ = U_NULL;
  202.         }
  203.  
  204.         if (insert9)
  205.         {
  206.             memmove(ptr, insert9, length9 * sizeof(wchar_t));
  207.             error[i].insert9 = ptr;
  208.             ptr += length9;
  209.             *ptr++ = U_NULL;
  210.         }
  211.     }
  212.  
  213.     error[i].num         = i;
  214.     error[i].left_token  = (left_token > right_token ? right_token : left_token);
  215.     error[i].right_token = right_token;
  216.     error[i].right_string_length = lex_stream -> NameStringLength(right_token);
  217.  
  218.     //
  219.     // Dump the error immediately ?
  220.     //
  221.     if (control.option.dump_errors)
  222.     {
  223.         PrintEmacsMessage(i);
  224.  
  225.         if (buffer.Length() > 0)
  226.         {
  227.             delete [] buffer[0];
  228.             buffer.Reset();
  229.         }
  230.         error.Reset(1); // we need at least 1 error in order for the return code to be set properly. See print_messages
  231.         Coutput.flush();
  232.     }
  233.  
  234.     return;
  235. }
  236.  
  237. void SemanticError::StaticInitializer()
  238. {
  239.     memset(warning, 0, _num_kinds * sizeof(bool));
  240.  
  241.     warning[INVALID_OPTION] = 1;
  242.     warning[CANNOT_OPEN_ZIP_FILE] = 1;
  243.     warning[CANNOT_OPEN_PATH_DIRECTORY] = 1;
  244.  
  245.     warning[EMPTY_DECLARATION] = 1;
  246.     warning[REDUNDANT_ABSTRACT] = 1;
  247.     warning[REDUNDANT_FINAL] = 1;
  248.     warning[REDUNDANT_PUBLIC] = 1;
  249.     warning[REDUNDANT_STATIC] = 1;
  250.     warning[OBSOLESCENT_ABSTRACT] = 1;
  251.     warning[OBSOLESCENT_BRACKETS] = 1;
  252.     warning[NO_TYPES] = 1;
  253.     warning[PARENT_TYPE_IN_UNNAMED_PACKAGE] = 1;
  254.  
  255.     warning[DEPRECATED_TYPE] = 1;
  256.     warning[DEPRECATED_FIELD] = 1;
  257.     warning[DEPRECATED_METHOD] = 1;
  258.     warning[DEPRECATED_CONSTRUCTOR] = 1;
  259.  
  260.     warning[UNNECESSARY_TYPE_IMPORT] = 1;
  261.     warning[MULTIPLE_PUBLIC_TYPES] = 1;
  262.     warning[TYPE_IN_MULTIPLE_FILES] = 1;
  263.     warning[MISMATCHED_TYPE_AND_FILE_NAMES] = 1;
  264.     warning[REFERENCE_TO_TYPE_IN_MISMATCHED_FILE] = 1;
  265.     warning[ONE_UNNAMED_PACKAGE] = 1;
  266.     warning[RECOMPILATION] = 1;
  267.     warning[METHOD_WITH_CONSTRUCTOR_NAME] = 1;
  268.  
  269.     warning[DEFAULT_METHOD_NOT_OVERRIDDEN] = 1;
  270.  
  271.     //
  272.     // TODO: Review the cases below. They should be flagged as errors.
  273.     //       However, since javac does not flag them at all, we only issue
  274.     //       a warning.
  275.     warning[STATIC_PROTECTED_FIELD_ACCESS] = 2;
  276.     warning[STATIC_PROTECTED_METHOD_ACCESS] = 2;
  277.     warning[INHERITANCE_AND_LEXICAL_SCOPING_CONFLICT_WITH_LOCAL] = 2;
  278.     warning[INHERITANCE_AND_LEXICAL_SCOPING_CONFLICT_WITH_MEMBER] = 2;
  279.     warning[PRIVATE_METHOD_OVERRIDE] = 1;
  280.     warning[PRIVATE_METHOD_OVERRIDE_EXTERNALLY] = 1;
  281.  
  282.     //
  283.     // Something stronger than a warning, but code will be generated anyway
  284.     //
  285.     warning[BAD_INPUT_FILE] = 2;
  286.     warning[UNREADABLE_INPUT_FILE] = 2;
  287.  
  288. //
  289. // TODO: Let these conditions be flagged as errors now.
  290. //
  291. //    warning[UNREACHABLE_CATCH_CLAUSE] = 2;
  292. //    warning[VARIABLE_NOT_DEFINITELY_ASSIGNED] = 2;
  293. //    warning[TARGET_VARIABLE_IS_FINAL] = 2;
  294. //    warning[FINAL_VARIABLE_TARGET_IN_LOOP] = 2;
  295. //    warning[VOID_TO_STRING] = 2;
  296. //
  297.  
  298. #ifdef TEST
  299.     for (int i = 0; i < _num_kinds; i++)
  300.         print_message[i] = NULL;
  301. #endif
  302.  
  303.     print_message[BAD_ERROR] = PrintBAD_ERROR;
  304.     print_message[DEFAULT_ERROR] = PrintDEFAULT_ERROR;
  305.     print_message[INVALID_OPTION] = PrintINVALID_OPTION;
  306.     print_message[INVALID_K_OPTION] = PrintINVALID_K_OPTION;
  307.     print_message[INVALID_K_TARGET] = PrintINVALID_K_TARGET;
  308.     print_message[INVALID_TAB_VALUE] = PrintINVALID_TAB_VALUE;
  309.     print_message[INVALID_DIRECTORY] = PrintINVALID_DIRECTORY;
  310.     print_message[UNSUPPORTED_OPTION] = PrintUNSUPPORTED_OPTION;
  311.     print_message[NO_CURRENT_DIRECTORY] = PrintNO_CURRENT_DIRECTORY;
  312.     print_message[CANNOT_OPEN_ZIP_FILE] = PrintCANNOT_OPEN_ZIP_FILE;
  313.     print_message[CANNOT_OPEN_PATH_DIRECTORY] = PrintCANNOT_OPEN_PATH_DIRECTORY;
  314.     print_message[PACKAGE_NOT_FOUND] = PrintPACKAGE_NOT_FOUND;
  315.     print_message[CANNOT_OPEN_DIRECTORY] = PrintCANNOT_OPEN_DIRECTORY;
  316.     print_message[BAD_INPUT_FILE] = PrintBAD_INPUT_FILE;
  317.     print_message[UNREADABLE_INPUT_FILE] = PrintUNREADABLE_INPUT_FILE;
  318.     print_message[NON_STANDARD_LIBRARY_TYPE] = PrintNON_STANDARD_LIBRARY_TYPE;
  319.     print_message[LIBRARY_METHOD_NOT_FOUND] = PrintLIBRARY_METHOD_NOT_FOUND;
  320.     print_message[CANNOT_REOPEN_FILE] = PrintCANNOT_REOPEN_FILE;
  321.     print_message[CANNOT_WRITE_FILE] = PrintCANNOT_WRITE_FILE;
  322.     print_message[CONSTANT_POOL_OVERFLOW] = PrintCONSTANT_POOL_OVERFLOW;
  323.     print_message[INTERFACES_OVERFLOW] = PrintINTERFACES_OVERFLOW;
  324.     print_message[METHODS_OVERFLOW] = PrintMETHODS_OVERFLOW;
  325.     print_message[STRING_OVERFLOW] = PrintSTRING_OVERFLOW;
  326.     print_message[PARAMETER_OVERFLOW] = PrintPARAMETER_OVERFLOW;
  327.     print_message[ARRAY_OVERFLOW] = PrintARRAY_OVERFLOW;
  328.     print_message[FIELDS_OVERFLOW] = PrintFIELDS_OVERFLOW;
  329.     print_message[LOCAL_VARIABLES_OVERFLOW] = PrintLOCAL_VARIABLES_OVERFLOW;
  330.     print_message[STACK_OVERFLOW] = PrintSTACK_OVERFLOW;
  331.     print_message[CODE_OVERFLOW] = PrintCODE_OVERFLOW;
  332.     print_message[CANNOT_COMPUTE_COLUMNS] = PrintCANNOT_COMPUTE_COLUMNS;
  333.     print_message[EMPTY_DECLARATION] = PrintEMPTY_DECLARATION;
  334.     print_message[REDUNDANT_ABSTRACT] = PrintREDUNDANT_ABSTRACT;
  335.     print_message[REDUNDANT_FINAL] = PrintREDUNDANT_FINAL;
  336.     print_message[REDUNDANT_PUBLIC] = PrintREDUNDANT_PUBLIC;
  337.     print_message[REDUNDANT_STATIC] = PrintREDUNDANT_STATIC;
  338.     print_message[OBSOLESCENT_ABSTRACT] = PrintOBSOLESCENT_ABSTRACT;
  339.     print_message[OBSOLESCENT_BRACKETS] = PrintOBSOLESCENT_BRACKETS;
  340.     print_message[NO_TYPES] = PrintNO_TYPES;
  341.     print_message[MULTIPLE_PUBLIC_TYPES] = PrintMULTIPLE_PUBLIC_TYPES;
  342.     print_message[TYPE_IN_MULTIPLE_FILES] = PrintTYPE_IN_MULTIPLE_FILES;
  343.     print_message[PACKAGE_TYPE_CONFLICT] = PrintPACKAGE_TYPE_CONFLICT;
  344.     print_message[DIRECTORY_FILE_CONFLICT] = PrintDIRECTORY_FILE_CONFLICT;
  345.     print_message[FILE_FILE_CONFLICT] = PrintFILE_FILE_CONFLICT;
  346.     print_message[MISMATCHED_TYPE_AND_FILE_NAMES] = PrintMISMATCHED_TYPE_AND_FILE_NAMES;
  347.     print_message[REFERENCE_TO_TYPE_IN_MISMATCHED_FILE] = PrintREFERENCE_TO_TYPE_IN_MISMATCHED_FILE;
  348.     print_message[DUPLICATE_INNER_TYPE_NAME] = PrintDUPLICATE_INNER_TYPE_NAME;
  349.     print_message[DUPLICATE_TYPE_DECLARATION] = PrintDUPLICATE_TYPE_DECLARATION;
  350.     print_message[UNNECESSARY_TYPE_IMPORT] = PrintUNNECESSARY_TYPE_IMPORT;
  351.     print_message[DUPLICATE_ACCESS_MODIFIER] = PrintDUPLICATE_ACCESS_MODIFIER;
  352.     print_message[DUPLICATE_MODIFIER] = PrintDUPLICATE_MODIFIER;
  353.     print_message[FINAL_ABSTRACT_CLASS] = PrintFINAL_ABSTRACT_CLASS;
  354.     print_message[VOLATILE_FINAL] = PrintVOLATILE_FINAL;
  355.     print_message[FINAL_VOLATILE] = PrintFINAL_VOLATILE;
  356.     print_message[INVALID_TOP_LEVEL_CLASS_MODIFIER] = PrintINVALID_TOP_LEVEL_CLASS_MODIFIER;
  357.     print_message[INVALID_INNER_CLASS_MODIFIER] = PrintINVALID_INNER_CLASS_MODIFIER;
  358.     print_message[INVALID_STATIC_INNER_CLASS_MODIFIER] = PrintINVALID_STATIC_INNER_CLASS_MODIFIER;
  359.     print_message[INVALID_LOCAL_CLASS_MODIFIER] = PrintINVALID_LOCAL_CLASS_MODIFIER;
  360.     print_message[INVALID_INTERFACE_MODIFIER] = PrintINVALID_INTERFACE_MODIFIER;
  361.     print_message[INVALID_FIELD_MODIFIER] = PrintINVALID_FIELD_MODIFIER;
  362.     print_message[INVALID_LOCAL_MODIFIER] = PrintINVALID_LOCAL_MODIFIER;
  363.     print_message[INVALID_METHOD_MODIFIER] = PrintINVALID_METHOD_MODIFIER;
  364.     print_message[INVALID_SIGNATURE_MODIFIER] = PrintINVALID_SIGNATURE_MODIFIER;
  365.     print_message[INVALID_CONSTRUCTOR_MODIFIER] = PrintINVALID_CONSTRUCTOR_MODIFIER;
  366.     print_message[INVALID_CONSTANT_MODIFIER] = PrintINVALID_CONSTANT_MODIFIER;
  367.     print_message[UNINITIALIZED_FIELD] = PrintUNINITIALIZED_FIELD;
  368.     print_message[PARENT_TYPE_IN_UNNAMED_PACKAGE] = PrintPARENT_TYPE_IN_UNNAMED_PACKAGE;
  369.     print_message[RECOMPILATION] = PrintRECOMPILATION;
  370.     print_message[TYPE_NOT_FOUND] = PrintTYPE_NOT_FOUND;
  371.     print_message[DUPLICATE_ON_DEMAND_IMPORT] = PrintDUPLICATE_ON_DEMAND_IMPORT;
  372.     print_message[NOT_A_TYPE] = PrintNOT_A_TYPE;
  373.     print_message[NOT_A_CLASS] = PrintNOT_A_CLASS;
  374.     print_message[NOT_AN_INTERFACE] = PrintNOT_AN_INTERFACE;
  375.     print_message[SUPER_IS_FINAL] = PrintSUPER_IS_FINAL;
  376.     print_message[OBJECT_WITH_SUPER_TYPE] = PrintOBJECT_WITH_SUPER_TYPE;
  377.     print_message[OBJECT_HAS_NO_SUPER_TYPE] = PrintOBJECT_HAS_NO_SUPER_TYPE;
  378.     print_message[DUPLICATE_FIELD] = PrintDUPLICATE_FIELD;
  379.     print_message[DUPLICATE_METHOD] = PrintDUPLICATE_METHOD;
  380.     print_message[DUPLICATE_CONSTRUCTOR] = PrintDUPLICATE_CONSTRUCTOR;
  381.     print_message[MISMATCHED_INHERITED_METHOD] = PrintMISMATCHED_INHERITED_METHOD;
  382.     print_message[MISMATCHED_INHERITED_METHOD_EXTERNALLY] = PrintMISMATCHED_INHERITED_METHOD_EXTERNALLY;
  383.     print_message[DUPLICATE_FORMAL_PARAMETER] = PrintDUPLICATE_FORMAL_PARAMETER;
  384.     print_message[MISMATCHED_CONSTRUCTOR_NAME] = PrintMISMATCHED_CONSTRUCTOR_NAME;
  385.     print_message[METHOD_WITH_CONSTRUCTOR_NAME] = PrintMETHOD_WITH_CONSTRUCTOR_NAME;
  386.     print_message[DUPLICATE_LOCAL_VARIABLE_DECLARATION] = PrintDUPLICATE_LOCAL_VARIABLE_DECLARATION;
  387.     print_message[DUPLICATE_LOCAL_TYPE_DECLARATION] = PrintDUPLICATE_LOCAL_TYPE_DECLARATION;
  388.     print_message[MULTIPLE_DEFAULT_LABEL] = PrintMULTIPLE_DEFAULT_LABEL;
  389.     print_message[UNDECLARED_LABEL] = PrintUNDECLARED_LABEL;
  390.     print_message[DUPLICATE_LABEL] = PrintDUPLICATE_LABEL;
  391.     print_message[CATCH_PRIMITIVE_TYPE] = PrintCATCH_PRIMITIVE_TYPE;
  392.     print_message[CATCH_ARRAY_TYPE] = PrintCATCH_ARRAY_TYPE;
  393.     print_message[AMBIGUOUS_FIELD] = PrintAMBIGUOUS_FIELD;
  394.     print_message[AMBIGUOUS_TYPE] = PrintAMBIGUOUS_TYPE;
  395.     print_message[FIELD_IS_TYPE] = PrintFIELD_IS_TYPE;
  396.     print_message[FIELD_NOT_FOUND] = PrintFIELD_NOT_FOUND;
  397.     print_message[FIELD_NAME_MISSPELLED] = PrintFIELD_NAME_MISSPELLED;
  398.     print_message[FIELD_WITH_PRIVATE_ACCESS_NOT_ACCESSIBLE] = PrintFIELD_WITH_PRIVATE_ACCESS_NOT_ACCESSIBLE;
  399.     print_message[FIELD_WITH_DEFAULT_ACCESS_NOT_ACCESSIBLE] = PrintFIELD_WITH_DEFAULT_ACCESS_NOT_ACCESSIBLE;
  400.     print_message[NAME_NOT_FOUND] = PrintNAME_NOT_FOUND;
  401.     print_message[METHOD_NOT_FIELD] = PrintMETHOD_NOT_FIELD;
  402.     print_message[NAME_NOT_YET_AVAILABLE] = PrintNAME_NOT_YET_AVAILABLE;
  403.     print_message[NAME_NOT_VARIABLE] = PrintNAME_NOT_VARIABLE;
  404.     print_message[NAME_NOT_CLASS_VARIABLE] = PrintNAME_NOT_CLASS_VARIABLE;
  405.     print_message[NOT_A_NUMERIC_VARIABLE] = PrintNOT_A_NUMERIC_VARIABLE;
  406.     print_message[METHOD_NOT_FOUND] = PrintMETHOD_NOT_FOUND;
  407.     print_message[METHOD_NAME_NOT_FOUND_IN_TYPE] = PrintMETHOD_NAME_NOT_FOUND_IN_TYPE;
  408.     print_message[METHOD_NAME_MISSPELLED] = PrintMETHOD_NAME_MISSPELLED;
  409.     print_message[METHOD_WITH_PRIVATE_ACCESS_NOT_ACCESSIBLE] = PrintMETHOD_WITH_PRIVATE_ACCESS_NOT_ACCESSIBLE;
  410.     print_message[METHOD_WITH_DEFAULT_ACCESS_NOT_ACCESSIBLE] = PrintMETHOD_WITH_DEFAULT_ACCESS_NOT_ACCESSIBLE;
  411.     print_message[HIDDEN_METHOD_IN_ENCLOSING_CLASS] = PrintHIDDEN_METHOD_IN_ENCLOSING_CLASS;
  412.     print_message[FIELD_NOT_METHOD] = PrintFIELD_NOT_METHOD;
  413.     print_message[TYPE_NOT_METHOD] = PrintTYPE_NOT_METHOD;
  414.     print_message[TYPE_NOT_FIELD] = PrintTYPE_NOT_FIELD;
  415.     print_message[METHOD_NOT_CLASS_METHOD] = PrintMETHOD_NOT_CLASS_METHOD;
  416.     print_message[AMBIGUOUS_CONSTRUCTOR_INVOCATION] = PrintAMBIGUOUS_CONSTRUCTOR_INVOCATION;
  417.     print_message[AMBIGUOUS_METHOD_INVOCATION] = PrintAMBIGUOUS_METHOD_INVOCATION;
  418.     print_message[CONSTRUCTOR_NOT_FOUND] = PrintCONSTRUCTOR_NOT_FOUND;
  419.     print_message[METHOD_FOUND_FOR_CONSTRUCTOR] = PrintMETHOD_FOUND_FOR_CONSTRUCTOR;
  420.     print_message[ABSTRACT_TYPE_CREATION] = PrintABSTRACT_TYPE_CREATION;
  421.     print_message[INVALID_INSTANCEOF_CONVERSION] = PrintINVALID_INSTANCEOF_CONVERSION;
  422.     print_message[INVALID_CAST_CONVERSION] = PrintINVALID_CAST_CONVERSION;
  423.     print_message[INVALID_CAST_TYPE] = PrintINVALID_CAST_TYPE;
  424.     print_message[INCOMPATIBLE_TYPE_FOR_INITIALIZATION] = PrintINCOMPATIBLE_TYPE_FOR_INITIALIZATION;
  425.     print_message[INCOMPATIBLE_TYPE_FOR_ASSIGNMENT] = PrintINCOMPATIBLE_TYPE_FOR_ASSIGNMENT;
  426.     print_message[INCOMPATIBLE_TYPE_FOR_BINARY_EXPRESSION] = PrintINCOMPATIBLE_TYPE_FOR_BINARY_EXPRESSION;
  427.     print_message[INCOMPATIBLE_TYPE_FOR_CONDITIONAL_EXPRESSION] = PrintINCOMPATIBLE_TYPE_FOR_CONDITIONAL_EXPRESSION;
  428.     print_message[VOID_ARRAY] = PrintVOID_ARRAY;
  429.     print_message[VOID_TYPE_IN_EQUALITY_EXPRESSION] = PrintVOID_TYPE_IN_EQUALITY_EXPRESSION;
  430.     print_message[TYPE_NOT_THROWABLE] = PrintTYPE_NOT_THROWABLE;
  431.     print_message[TYPE_NOT_PRIMITIVE] = PrintTYPE_NOT_PRIMITIVE;
  432.     print_message[TYPE_NOT_INTEGRAL] = PrintTYPE_NOT_INTEGRAL;
  433.     print_message[TYPE_NOT_NUMERIC] = PrintTYPE_NOT_NUMERIC;
  434.     print_message[TYPE_NOT_INTEGER] = PrintTYPE_NOT_INTEGER;
  435.     print_message[TYPE_NOT_BOOLEAN] = PrintTYPE_NOT_BOOLEAN;
  436.     print_message[TYPE_NOT_ARRAY] = PrintTYPE_NOT_ARRAY;
  437.     print_message[TYPE_NOT_REFERENCE] = PrintTYPE_NOT_REFERENCE;
  438.     print_message[TYPE_NOT_VALID_FOR_SWITCH] = PrintTYPE_NOT_VALID_FOR_SWITCH;
  439.     print_message[TYPE_IS_VOID] = PrintTYPE_IS_VOID;
  440.     print_message[VALUE_NOT_REPRESENTABLE_IN_SWITCH_TYPE] = PrintVALUE_NOT_REPRESENTABLE_IN_SWITCH_TYPE;
  441.     print_message[TYPE_NOT_CONVERTIBLE_TO_SWITCH_TYPE] = PrintTYPE_NOT_CONVERTIBLE_TO_SWITCH_TYPE;
  442.     print_message[DUPLICATE_CASE_VALUE] = PrintDUPLICATE_CASE_VALUE;
  443.     print_message[MISPLACED_THIS_EXPRESSION] = PrintMISPLACED_THIS_EXPRESSION;
  444.     print_message[MISPLACED_SUPER_EXPRESSION] = PrintMISPLACED_SUPER_EXPRESSION;
  445.     print_message[TARGET_VARIABLE_IS_FINAL] = PrintTARGET_VARIABLE_IS_FINAL;
  446.     print_message[FINAL_VARIABLE_TARGET_IN_LOOP] = PrintFINAL_VARIABLE_TARGET_IN_LOOP;
  447.     print_message[UNINITIALIZED_FINAL_VARIABLE] = PrintUNINITIALIZED_FINAL_VARIABLE;
  448.     print_message[UNINITIALIZED_STATIC_FINAL_VARIABLE] = PrintUNINITIALIZED_STATIC_FINAL_VARIABLE;
  449.     print_message[UNINITIALIZED_FINAL_VARIABLE_IN_CONSTRUCTOR] = PrintUNINITIALIZED_FINAL_VARIABLE_IN_CONSTRUCTOR;
  450.     print_message[INIT_SCALAR_WITH_ARRAY] = PrintINIT_SCALAR_WITH_ARRAY;
  451.     print_message[INIT_ARRAY_WITH_SCALAR] = PrintINIT_ARRAY_WITH_SCALAR;
  452.     print_message[INVALID_BYTE_VALUE] = PrintINVALID_BYTE_VALUE;
  453.     print_message[INVALID_SHORT_VALUE] = PrintINVALID_SHORT_VALUE;
  454.     print_message[INVALID_CHARACTER_VALUE] = PrintINVALID_CHARACTER_VALUE;
  455.     print_message[INVALID_INT_VALUE] = PrintINVALID_INT_VALUE;
  456.     print_message[INVALID_LONG_VALUE] = PrintINVALID_LONG_VALUE;
  457.     print_message[INVALID_FLOAT_VALUE] = PrintINVALID_FLOAT_VALUE;
  458.     print_message[INVALID_DOUBLE_VALUE] = PrintINVALID_DOUBLE_VALUE;
  459.     print_message[INVALID_STRING_VALUE] = PrintINVALID_STRING_VALUE;
  460.     print_message[RETURN_STATEMENT_IN_INITIALIZER] = PrintRETURN_STATEMENT_IN_INITIALIZER;
  461.     print_message[MISPLACED_RETURN_WITH_EXPRESSION] = PrintMISPLACED_RETURN_WITH_EXPRESSION;
  462.     print_message[MISPLACED_RETURN_WITH_NO_EXPRESSION] = PrintMISPLACED_RETURN_WITH_NO_EXPRESSION;
  463.     print_message[MISMATCHED_RETURN_AND_METHOD_TYPE] = PrintMISMATCHED_RETURN_AND_METHOD_TYPE;
  464.     print_message[EXPRESSION_NOT_THROWABLE] = PrintEXPRESSION_NOT_THROWABLE;
  465.     print_message[BAD_THROWABLE_EXPRESSION_IN_TRY] = PrintBAD_THROWABLE_EXPRESSION_IN_TRY;
  466.     print_message[BAD_THROWABLE_EXPRESSION_IN_METHOD] = PrintBAD_THROWABLE_EXPRESSION_IN_METHOD;
  467.     print_message[BAD_THROWABLE_EXPRESSION] = PrintBAD_THROWABLE_EXPRESSION;
  468.     print_message[MISPLACED_BREAK_STATEMENT] = PrintMISPLACED_BREAK_STATEMENT;
  469.     print_message[MISPLACED_CONTINUE_STATEMENT] = PrintMISPLACED_CONTINUE_STATEMENT;
  470.     print_message[MISPLACED_EXPLICIT_CONSTRUCTOR_INVOCATION] = PrintMISPLACED_EXPLICIT_CONSTRUCTOR_INVOCATION;
  471.     print_message[INVALID_CONTINUE_TARGET] = PrintINVALID_CONTINUE_TARGET;
  472.     print_message[NON_ABSTRACT_TYPE_CONTAINS_ABSTRACT_METHOD] = PrintNON_ABSTRACT_TYPE_CONTAINS_ABSTRACT_METHOD;
  473.     print_message[NON_ABSTRACT_TYPE_INHERITS_ABSTRACT_METHOD] = PrintNON_ABSTRACT_TYPE_INHERITS_ABSTRACT_METHOD;
  474.     print_message[NON_ABSTRACT_TYPE_INHERITS_ABSTRACT_METHOD_FROM_ABSTRACT_CLASS] = PrintNON_ABSTRACT_TYPE_INHERITS_ABSTRACT_METHOD_FROM_ABSTRACT_CLASS;
  475.     print_message[NON_ABSTRACT_TYPE_CANNOT_OVERRIDE_DEFAULT_ABSTRACT_METHOD] = PrintNON_ABSTRACT_TYPE_CANNOT_OVERRIDE_DEFAULT_ABSTRACT_METHOD;
  476.     print_message[NO_ABSTRACT_METHOD_IMPLEMENTATION] = PrintNO_ABSTRACT_METHOD_IMPLEMENTATION;
  477.     print_message[DUPLICATE_INTERFACE] = PrintDUPLICATE_INTERFACE;
  478.     print_message[UNKNOWN_QUALIFIED_NAME_BASE] = PrintUNKNOWN_QUALIFIED_NAME_BASE;
  479.     print_message[UNKNOWN_AMBIGUOUS_NAME] = PrintUNKNOWN_AMBIGUOUS_NAME;
  480.     print_message[CIRCULAR_INTERFACE] = PrintCIRCULAR_INTERFACE;
  481.     print_message[CIRCULAR_CLASS] = PrintCIRCULAR_CLASS;
  482.     print_message[TYPE_NOT_ACCESSIBLE] = PrintTYPE_NOT_ACCESSIBLE;
  483.     print_message[PRIVATE_FIELD_NOT_ACCESSIBLE] = PrintPRIVATE_FIELD_NOT_ACCESSIBLE;
  484.     print_message[PROTECTED_FIELD_NOT_ACCESSIBLE] = PrintPROTECTED_FIELD_NOT_ACCESSIBLE;
  485.     print_message[DEFAULT_FIELD_NOT_ACCESSIBLE] = PrintDEFAULT_FIELD_NOT_ACCESSIBLE;
  486.     print_message[PRIVATE_METHOD_NOT_ACCESSIBLE] = PrintPRIVATE_METHOD_NOT_ACCESSIBLE;
  487.     print_message[PROTECTED_METHOD_NOT_ACCESSIBLE] = PrintPROTECTED_METHOD_NOT_ACCESSIBLE;
  488.     print_message[DEFAULT_METHOD_NOT_ACCESSIBLE] = PrintDEFAULT_METHOD_NOT_ACCESSIBLE;
  489.     print_message[PRIVATE_CONSTRUCTOR_NOT_ACCESSIBLE] = PrintPRIVATE_CONSTRUCTOR_NOT_ACCESSIBLE;
  490.     print_message[PROTECTED_CONSTRUCTOR_NOT_ACCESSIBLE] = PrintPROTECTED_CONSTRUCTOR_NOT_ACCESSIBLE;
  491.     print_message[DEFAULT_CONSTRUCTOR_NOT_ACCESSIBLE] = PrintDEFAULT_CONSTRUCTOR_NOT_ACCESSIBLE;
  492.     print_message[CONSTRUCTOR_DOES_NOT_THROW_THIS_EXCEPTION] = PrintCONSTRUCTOR_DOES_NOT_THROW_THIS_EXCEPTION;
  493.     print_message[CONSTRUCTOR_DOES_NOT_THROW_SUPER_EXCEPTION] = PrintCONSTRUCTOR_DOES_NOT_THROW_SUPER_EXCEPTION;
  494.     print_message[PARAMETER_REDECLARED] = PrintPARAMETER_REDECLARED;
  495.     print_message[BAD_ABSTRACT_METHOD_MODIFIER] = PrintBAD_ABSTRACT_METHOD_MODIFIER;
  496.     print_message[ABSTRACT_METHOD_MODIFIER_CONFLICT] = PrintABSTRACT_METHOD_MODIFIER_CONFLICT;
  497.     print_message[ABSTRACT_METHOD_INVOCATION] = PrintABSTRACT_METHOD_INVOCATION;
  498.     print_message[FINAL_METHOD_OVERRIDE] = PrintFINAL_METHOD_OVERRIDE;
  499.     print_message[FINAL_METHOD_OVERRIDE_EXTERNALLY] = PrintFINAL_METHOD_OVERRIDE_EXTERNALLY;
  500.     print_message[PRIVATE_METHOD_OVERRIDE] = PrintPRIVATE_METHOD_OVERRIDE;
  501.     print_message[PRIVATE_METHOD_OVERRIDE_EXTERNALLY] = PrintPRIVATE_METHOD_OVERRIDE_EXTERNALLY;
  502.     print_message[INSTANCE_METHOD_OVERRIDE] = PrintINSTANCE_METHOD_OVERRIDE;
  503.     print_message[INSTANCE_METHOD_OVERRIDE_EXTERNALLY] = PrintINSTANCE_METHOD_OVERRIDE_EXTERNALLY;
  504.     print_message[CLASS_METHOD_OVERRIDE] = PrintCLASS_METHOD_OVERRIDE;
  505.     print_message[CLASS_METHOD_OVERRIDE_EXTERNALLY] = PrintCLASS_METHOD_OVERRIDE_EXTERNALLY;
  506.     print_message[MISMATCHED_OVERRIDDEN_EXCEPTION] = PrintMISMATCHED_OVERRIDDEN_EXCEPTION;
  507.     print_message[MISMATCHED_OVERRIDDEN_EXCEPTION_EXTERNALLY] = PrintMISMATCHED_OVERRIDDEN_EXCEPTION_EXTERNALLY;
  508.     print_message[ABSTRACT_METHOD_WITH_BODY] = PrintABSTRACT_METHOD_WITH_BODY;
  509.     print_message[NON_ABSTRACT_METHOD_WITHOUT_BODY] = PrintNON_ABSTRACT_METHOD_WITHOUT_BODY;
  510.     print_message[BAD_ACCESS_METHOD_OVERRIDE] = PrintBAD_ACCESS_METHOD_OVERRIDE;
  511.     print_message[BAD_ACCESS_METHOD_OVERRIDE_EXTERNALLY] = PrintBAD_ACCESS_METHOD_OVERRIDE_EXTERNALLY;
  512.     print_message[STATIC_OVERRIDE_ABSTRACT] = PrintSTATIC_OVERRIDE_ABSTRACT;
  513.     print_message[STATIC_OVERRIDE_ABSTRACT_EXTERNALLY] = PrintSTATIC_OVERRIDE_ABSTRACT_EXTERNALLY;
  514.     print_message[CIRCULAR_THIS_CALL] = PrintCIRCULAR_THIS_CALL;
  515.     print_message[INSTANCE_VARIABLE_IN_EXPLICIT_CONSTRUCTOR_INVOCATION] = PrintINSTANCE_VARIABLE_IN_EXPLICIT_CONSTRUCTOR_INVOCATION;
  516.     print_message[INSTANCE_METHOD_IN_EXPLICIT_CONSTRUCTOR_INVOCATION] = PrintINSTANCE_METHOD_IN_EXPLICIT_CONSTRUCTOR_INVOCATION;
  517.     print_message[SYNTHETIC_VARIABLE_ACCESS] = PrintSYNTHETIC_VARIABLE_ACCESS;
  518.     print_message[SYNTHETIC_METHOD_INVOCATION] = PrintSYNTHETIC_METHOD_INVOCATION;
  519.     print_message[SYNTHETIC_CONSTRUCTOR_INVOCATION] = PrintSYNTHETIC_CONSTRUCTOR_INVOCATION;
  520.     print_message[THIS_IN_EXPLICIT_CONSTRUCTOR_INVOCATION] = PrintTHIS_IN_EXPLICIT_CONSTRUCTOR_INVOCATION;
  521.     print_message[SUPER_IN_EXPLICIT_CONSTRUCTOR_INVOCATION] = PrintSUPER_IN_EXPLICIT_CONSTRUCTOR_INVOCATION;
  522.     print_message[INNER_CONSTRUCTOR_IN_EXPLICIT_CONSTRUCTOR_INVOCATION] = PrintINNER_CONSTRUCTOR_IN_EXPLICIT_CONSTRUCTOR_INVOCATION;
  523.     print_message[EXPRESSION_NOT_CONSTANT] = PrintEXPRESSION_NOT_CONSTANT;
  524.     print_message[UNCATCHABLE_METHOD_THROWN_CHECKED_EXCEPTION] = PrintUNCATCHABLE_METHOD_THROWN_CHECKED_EXCEPTION;
  525.     print_message[UNCATCHABLE_CONSTRUCTOR_THROWN_CHECKED_EXCEPTION] = PrintUNCATCHABLE_CONSTRUCTOR_THROWN_CHECKED_EXCEPTION;
  526.     print_message[UNREACHABLE_CATCH_CLAUSE] = PrintUNREACHABLE_CATCH_CLAUSE;
  527.     print_message[UNREACHABLE_STATEMENT] = PrintUNREACHABLE_STATEMENT;
  528.     print_message[UNREACHABLE_STATEMENTS] = PrintUNREACHABLE_STATEMENTS;
  529.     print_message[UNREACHABLE_CONSTRUCTOR_BODY] = PrintUNREACHABLE_CONSTRUCTOR_BODY;
  530.     print_message[BLOCKED_CATCH_CLAUSE] = PrintBLOCKED_CATCH_CLAUSE;
  531.     print_message[VARIABLE_NOT_DEFINITELY_ASSIGNED] = PrintVARIABLE_NOT_DEFINITELY_ASSIGNED;
  532.     print_message[TYPED_METHOD_WITH_NO_RETURN] = PrintTYPED_METHOD_WITH_NO_RETURN;
  533.  
  534.     print_message[DEFAULT_METHOD_NOT_OVERRIDDEN] = PrintDEFAULT_METHOD_NOT_OVERRIDDEN;
  535.  
  536.     print_message[ONE_UNNAMED_PACKAGE] = PrintONE_UNNAMED_PACKAGE;
  537.     print_message[TYPE_NOT_IN_UNNAMED_PACKAGE] = PrintTYPE_NOT_IN_UNNAMED_PACKAGE;
  538.     print_message[TYPE_IN_WRONG_PACKAGE] = PrintTYPE_IN_WRONG_PACKAGE;
  539.     print_message[TYPE_NAME_MISMATCH] = PrintTYPE_NAME_MISMATCH;
  540.  
  541.     print_message[DEPRECATED_TYPE] = PrintDEPRECATED_TYPE;
  542.     print_message[DEPRECATED_FIELD] = PrintDEPRECATED_FIELD;
  543.     print_message[DEPRECATED_METHOD] = PrintDEPRECATED_METHOD;
  544.     print_message[DEPRECATED_CONSTRUCTOR] = PrintDEPRECATED_CONSTRUCTOR;
  545.  
  546.     print_message[COMPRESSED_ZIP_FILE] = PrintCOMPRESSED_ZIP_FILE;
  547.     print_message[INVALID_CLASS_FILE] = PrintINVALID_CLASS_FILE;
  548.     print_message[CANNOT_OPEN_CLASS_FILE] = PrintCANNOT_OPEN_CLASS_FILE;
  549.  
  550.     print_message[ONE_ONE_FEATURE] = PrintONE_ONE_FEATURE;
  551.     print_message[STATIC_NOT_INNER_CLASS] = PrintSTATIC_NOT_INNER_CLASS;
  552.     print_message[TYPE_NOT_INNER_CLASS] = PrintTYPE_NOT_INNER_CLASS;
  553.     print_message[SUPER_TYPE_NOT_INNER_CLASS] = PrintSUPER_TYPE_NOT_INNER_CLASS;
  554.     print_message[STATIC_FIELD_IN_INNER_CLASS] = PrintSTATIC_FIELD_IN_INNER_CLASS;
  555.     print_message[STATIC_METHOD_IN_INNER_CLASS] = PrintSTATIC_METHOD_IN_INNER_CLASS;
  556.     print_message[STATIC_TYPE_IN_INNER_CLASS] = PrintSTATIC_TYPE_IN_INNER_CLASS;
  557.     print_message[STATIC_INITIALIZER_IN_INNER_CLASS] = PrintSTATIC_INITIALIZER_IN_INNER_CLASS;
  558.     print_message[INNER_CLASS_REFERENCE_TO_NON_FINAL_LOCAL_VARIABLE] = PrintINNER_CLASS_REFERENCE_TO_NON_FINAL_LOCAL_VARIABLE;
  559.     print_message[STATIC_PROTECTED_FIELD_ACCESS] = PrintSTATIC_PROTECTED_FIELD_ACCESS;
  560.     print_message[STATIC_PROTECTED_METHOD_ACCESS] = PrintSTATIC_PROTECTED_METHOD_ACCESS;
  561.     print_message[INHERITANCE_AND_LEXICAL_SCOPING_CONFLICT_WITH_LOCAL] = PrintINHERITANCE_AND_LEXICAL_SCOPING_CONFLICT_WITH_LOCAL;
  562.     print_message[INHERITANCE_AND_LEXICAL_SCOPING_CONFLICT_WITH_MEMBER] = PrintINHERITANCE_AND_LEXICAL_SCOPING_CONFLICT_WITH_MEMBER;
  563.     print_message[ILLEGAL_THIS_FIELD_ACCESS] = PrintILLEGAL_THIS_FIELD_ACCESS;
  564.     print_message[CONSTRUCTOR_FOUND_IN_ANONYMOUS_CLASS] = PrintCONSTRUCTOR_FOUND_IN_ANONYMOUS_CLASS;
  565.     print_message[ENCLOSING_INSTANCE_NOT_ACCESSIBLE] = PrintENCLOSING_INSTANCE_NOT_ACCESSIBLE;
  566.     print_message[INVALID_ENCLOSING_INSTANCE] = PrintINVALID_ENCLOSING_INSTANCE;
  567.     print_message[ZERO_DIVIDE] = PrintZERO_DIVIDE;
  568.     print_message[VOID_TO_STRING] = PrintVOID_TO_STRING;
  569.  
  570. #ifdef TEST
  571.     //
  572.     // Make sure that there is a message associated with each code
  573.     //
  574.     for (int k = 0; k < _num_kinds; k++)
  575.         assert(print_message[k] != NULL);
  576. #endif
  577. }
  578.  
  579.  
  580. //
  581. // This procedure uses a  quick sort algorithm to sort the ERRORS
  582. // by the left_line_no and left_column_no fields.
  583. //
  584. void SemanticError::SortMessages()
  585. {
  586.      int lower,
  587.          upper,
  588.          lostack[32],
  589.          histack[32];
  590.  
  591.      int top,
  592.          i,
  593.          j;
  594.      ErrorInfo pivot,
  595.                temp;
  596.  
  597.      top = 0;
  598.      lostack[top] = 0;
  599.      histack[top] = error.Length() - 1;
  600.  
  601.      while(top >= 0)
  602.      {
  603.          lower = lostack[top];
  604.          upper = histack[top];
  605.          top--;
  606.  
  607.          while(upper > lower)
  608.          {
  609.              //
  610.              // The array is most-likely almost sorted. Therefore,
  611.              // we use the middle element as the pivot element.
  612.              //
  613.              i = (lower + upper) / 2;
  614.              pivot = error[i];
  615.              error[i] = error[lower];
  616.  
  617.              //
  618.              // Split the array section indicated by LOWER and UPPER
  619.              // using ARRAY(LOWER) as the pivot.
  620.              //
  621.              i = lower;
  622.              for (j = lower + 1; j <= upper; j++)
  623.                  if ((error[j].left_token < pivot.left_token) ||
  624.                  //
  625.                  // When two error messages start in the same location
  626.                  // and one is nested inside the other, the outer one
  627.                  // is placed first so that it can be printed last.
  628.                  // Recall that its right-span location is reached
  629.                  // after the inner one has been completely processed.
  630.                  //
  631.                      (error[j].left_token == pivot.left_token &&
  632.                       error[j].right_token > pivot.right_token) ||
  633.                  //
  634.                  // When two error messages are at the same location
  635.                  // span, check the NUM field to keep the sort stable.
  636.                  // When the location spans only a single symbol,
  637.                  // the one with the lowest "num" is placed first.
  638.                  //
  639.                      (error[j].left_token  == pivot.left_token  &&
  640.                       error[j].right_token == pivot.right_token &&
  641.                       pivot.left_token == pivot.right_token     &&
  642.                       error[j].num < pivot.num)                       ||
  643.                  //
  644.                  // When two error messages are at the same location
  645.                  // which spans more than one symbol in the source,
  646.                  // the first message is treated as being nested into
  647.                  // the second message and (just like the nested case
  648.                  // above) it is placed last in the sorted sequence.
  649.                  //
  650.                      (error[j].left_token  == pivot.left_token  &&
  651.                       error[j].right_token == pivot.right_token &&
  652.                       pivot.left_token < pivot.right_token      &&
  653.                       error[j].num > pivot.num))
  654.                  {
  655.                      temp = error[++i];
  656.                      error[i] = error[j];
  657.                      error[j] = temp;
  658.                  }
  659.              error[lower] = error[i];
  660.              error[i] = pivot;
  661.  
  662.              top++;
  663.              if ((i - lower) < (upper - i))
  664.              {
  665.                  lostack[top] = i + 1;
  666.                  histack[top] = upper;
  667.                  upper = i - 1;
  668.              }
  669.              else
  670.              {
  671.                  histack[top] = i - 1;
  672.                  lostack[top] = lower;
  673.                  lower = i + 1;
  674.              }
  675.          }
  676.      }
  677.  
  678.      return;
  679. }
  680.  
  681.  
  682. //
  683. // This is the local private procedure that prints the semantic error messages.
  684. //
  685. int SemanticError::PrintMessages()
  686. {
  687.     int return_code = (num_errors > 0 ? 1 : 0);
  688.  
  689.     //
  690.     // If the errors have not yet been dumped,...
  691.     //
  692.     if (! control.option.dump_errors)
  693.     {
  694.         if (control.option.errors)
  695.         {
  696.             if (num_errors == 0)
  697.             {
  698.                 if (control.option.nowarn) // we only had warnings and they should not be reported
  699.                     return return_code;
  700.  
  701.                 Coutput << "\nIssued "
  702.                         << num_warnings
  703.                         << (lex_stream -> file_symbol -> semantic == control.system_semantic ? " system" : " semantic")
  704.                         << " warning" << (num_warnings <= 1 ? "" : "s");
  705.             }
  706.             else // we had some errors, and possibly warnings as well
  707.             {
  708.                 Coutput << "\nFound "
  709.                         << num_errors
  710.                         << (lex_stream -> file_symbol -> semantic == control.system_semantic ? " system" : " semantic")
  711.                         << " error" << (num_errors <= 1 ? "" : "s");
  712.                 if (num_warnings > 0 && !control.option.nowarn)
  713.                 {
  714.                      Coutput << " and issued "
  715.                              << num_warnings << " warning" << (num_warnings <= 1 ? "" : "s");
  716.                 }
  717.             }
  718.  
  719.             if (lex_stream -> file_symbol -> semantic != control.system_semantic)
  720.             {
  721.                 Coutput << " compiling \""
  722.                         << lex_stream -> FileName()
  723.                         << '\"';
  724.             }
  725.             Coutput << ':';
  726.  
  727.             //
  728.             //
  729.             //
  730.             if (lex_stream -> file_symbol -> semantic != control.system_semantic)
  731.             {
  732.                 lex_stream -> RereadInput();
  733.  
  734.                 if (! lex_stream -> InputBuffer())
  735.                 {
  736.                     char *file_name = lex_stream -> FileName();
  737.                     int length = lex_stream -> FileNameLength();
  738.                     wchar_t *name = new wchar_t[length + 1];
  739.                     for (int i = 0; i < length; i++)
  740.                         name[i] = file_name[i];
  741.                     name[length] = U_NULL;
  742.                     control.system_semantic -> ReportSemError(SemanticError::CANNOT_REOPEN_FILE,
  743.                                                               0,
  744.                                                               0,
  745.                                                               name);
  746.                     delete [] name;
  747.                 }
  748.             }
  749.  
  750.             if (lex_stream -> file_symbol -> semantic == control.system_semantic || lex_stream -> InputBuffer())
  751.             {
  752.                 SortMessages();
  753.                 for (int k = 0; k < error.Length(); k++)
  754.                 {
  755.                     if ((warning[error[k].msg_code] != 1) || (! control.option.nowarn))
  756.                     {
  757.                         if (error[k].left_token < error[k].right_token)
  758.                              PrintLargeSource(k);
  759.                         else PrintSmallSource(k);
  760.                         Coutput << "\n*** " << (warning[error[k].msg_code] == 1
  761.                                                     ? "Warning: "
  762.                                                     : (warning[error[k].msg_code] == 2 && (! control.option.zero_defect)
  763.                                                               ? "Caution: "
  764.                                                               : "Error: "));
  765.                         (print_message[error[k].msg_code]) (error[k], lex_stream, control);
  766.                         Coutput << '\n';
  767.                     }
  768.                 }
  769.                 lex_stream -> DestroyInput();
  770.             }
  771.         }
  772.         else
  773.         {
  774.             if (lex_stream -> file_symbol -> semantic != control.system_semantic)
  775.             {
  776.                 if (! lex_stream -> ComputeColumns())
  777.                 {
  778.                     char *file_name = lex_stream -> FileName();
  779.                     int length = lex_stream -> FileNameLength();
  780.                     wchar_t *name = new wchar_t[length + 1];
  781.                     for (int i = 0; i < length; i++)
  782.                         name[i] = file_name[i];
  783.                     name[length] = U_NULL;
  784.                     control.system_semantic -> ReportSemError(SemanticError::CANNOT_COMPUTE_COLUMNS,
  785.                                                               0,
  786.                                                               0,
  787.                                                               name);
  788.                     delete [] name;
  789.                 }
  790.             }
  791.  
  792.             SortMessages();
  793.             for (int k = 0; k < error.Length(); k++)
  794.             {
  795.                 if ((warning[error[k].msg_code] != 1) || (! control.option.nowarn))
  796.                     PrintEmacsMessage(k);
  797.             }
  798.         }
  799.     }
  800.  
  801.     Coutput.flush();
  802.  
  803.     return return_code;
  804. }
  805.  
  806.  
  807. void SemanticError::PrintEmacsMessage(int k)
  808. {
  809.     int left_line_no    = lex_stream -> Line(error[k].left_token),
  810.         left_column_no  = lex_stream -> Column(error[k].left_token),
  811.         right_line_no   = lex_stream -> Line(error[k].right_token),
  812.         right_column_no = lex_stream -> Column(error[k].right_token);
  813.  
  814.     if (right_column_no != 0) // could not compute a column number
  815.         right_column_no += (error[k].right_string_length - 1); // point to last character in right token
  816.  
  817.     Coutput << lex_stream -> FileName()
  818.             << ':' << left_line_no  << ':' << left_column_no
  819.             << ':' << right_line_no << ':' << right_column_no
  820.             << (warning[error[k].msg_code] == 1
  821.                        ? ": Warning: "
  822.                        : (warning[error[k].msg_code] == 2  && (! control.option.zero_defect)
  823.                                  ? ": Caution: "
  824.                                  : ": Error: "));
  825.     (print_message[error[k].msg_code]) (error[k], lex_stream, control);
  826.     Coutput << '\n';
  827.  
  828.     return;
  829. }
  830.  
  831.  
  832. //
  833. // This procedure is invoked to print a large message that may
  834. // span more than one line. The parameter message points to the
  835. // starting line. The parameter k points to the error message in
  836. // the error structure.
  837. //
  838. void SemanticError::PrintLargeSource(int k)
  839. {
  840.     int left_line_no    = lex_stream -> Line(error[k].left_token),
  841.         left_column_no  = lex_stream -> Column(error[k].left_token),
  842.         right_line_no   = lex_stream -> Line(error[k].right_token),
  843.         right_column_no = lex_stream -> Column(error[k].right_token);
  844.  
  845.     if (left_line_no == right_line_no)
  846.     {
  847.         if (left_line_no == 0)
  848.             Coutput << "\n";
  849.         else
  850.         {
  851.             Coutput << "\n\n";
  852.             Coutput.width(6);
  853.             Coutput << left_line_no << ". ";
  854.             for (int i = lex_stream -> LineStart(left_line_no); i <= lex_stream -> LineEnd(left_line_no); i++)
  855.                 Coutput << lex_stream -> InputBuffer()[i];
  856.  
  857.             int offset = lex_stream -> WcharOffset(error[k].left_token, error[k].right_token);
  858.             Coutput.width(left_column_no + 8);
  859.             Coutput << "<";
  860.             Coutput.width(right_column_no + error[k].right_string_length - left_column_no - 1 + offset);
  861.             Coutput.fill('-');
  862.             Coutput << ">";
  863.             Coutput.fill(' ');
  864.         }
  865.     }
  866.     else
  867.     {
  868.         Coutput << "\n\n";
  869.         Coutput.width(left_column_no + 8);
  870.         Coutput << "<";
  871.  
  872.         Coutput.width(lex_stream -> LineSegmentLength(error[k].left_token));
  873.         Coutput.fill('-');
  874.         Coutput << "\n";
  875.         Coutput.fill(' ');
  876.  
  877.         Coutput.width(6);
  878.         Coutput << left_line_no << ". ";
  879.         for (int i = lex_stream -> LineStart(left_line_no); i <= lex_stream -> LineEnd(left_line_no); i++)
  880.             Coutput << lex_stream -> InputBuffer()[i];
  881.  
  882.         if (right_line_no > left_line_no + 1)
  883.         {
  884.             Coutput.width(left_column_no + 7);
  885.             Coutput << " ";
  886.             Coutput << ". . .\n";
  887.         }
  888.  
  889.         Coutput.width(6);
  890.         Coutput << right_line_no << ". ";
  891.         for (int j = lex_stream -> LineStart(right_line_no); j <= lex_stream -> LineEnd(right_line_no); j++)
  892.             Coutput << lex_stream -> InputBuffer()[j];
  893.  
  894.         int offset = lex_stream -> WcharOffset(error[k].right_token);
  895.         Coutput.width(8);
  896.         Coutput << "";
  897.         Coutput.width(right_column_no + error[k].right_string_length - 1 + offset);
  898.         Coutput.fill('-');
  899.         Coutput << ">";
  900.         Coutput.fill(' ');
  901.     }
  902.  
  903.     return;
  904. }
  905.  
  906. //
  907. // This procedure is invoked to print a small message that may
  908. // only span a single line. The parameter k points to the error
  909. // message in the error structure.
  910. //
  911. void SemanticError::PrintSmallSource(int k)
  912. {
  913.     int left_line_no = lex_stream -> Line(error[k].left_token);
  914.  
  915.     if (left_line_no == 0)
  916.         Coutput << "\n";
  917.     else
  918.     {
  919.         Coutput << "\n\n";
  920.         Coutput.width(6);
  921.         Coutput << left_line_no;
  922.         Coutput << ". ";
  923.         for (int i = lex_stream -> LineStart(left_line_no); i <= lex_stream -> LineEnd(left_line_no); i++)
  924.             Coutput << lex_stream -> InputBuffer()[i];
  925.  
  926.         int left_column_no = lex_stream -> Column(error[k].left_token),
  927.             right_column_no = lex_stream -> Column(error[k].right_token);
  928.  
  929.         Coutput.width(left_column_no + 7);
  930.         Coutput << "";
  931.         if (left_column_no == right_column_no && error[k].right_string_length == 1)
  932.             Coutput << '^';
  933.         else
  934.         {
  935.             int offset = lex_stream -> WcharOffset(error[k].left_token, error[k].right_token);
  936.             Coutput << '<';
  937.             Coutput.width(right_column_no + error[k].right_string_length - left_column_no - 1 + offset);
  938.             Coutput.fill('-');
  939.             Coutput << ">";
  940.             Coutput.fill(' ');
  941.         }
  942.     }
  943.  
  944.     return;
  945. }
  946.  
  947.  
  948. //
  949. // These "print_" procedures are invoked to print specific
  950. // error messages. The parameter err identifies the error to
  951. // be processed.
  952. //
  953. void SemanticError::PrintBAD_ERROR(ErrorInfo &err, LexStream *lex_stream, Control &control)
  954. {
  955.     fprintf(stderr, "chaos: Error code %i is not a valid error message code.\n", err.msg_code);
  956.  
  957.     return;
  958. }
  959.  
  960.  
  961. void SemanticError::PrintDEFAULT_ERROR(ErrorInfo &err, LexStream *lex_stream, Control &control)
  962. {
  963.     if (err.insert1)
  964.         Coutput << err.insert1;
  965.     if (err.insert2)
  966.         Coutput << err.insert2;
  967.     if (err.insert3)
  968.         Coutput << err.insert3;
  969.     if (err.insert4)
  970.         Coutput << err.insert4;
  971.     if (err.insert5)
  972.         Coutput << err.insert5;
  973.     if (err.insert6)
  974.         Coutput << err.insert6;
  975.     if (err.insert7)
  976.         Coutput << err.insert7;
  977.     if (err.insert8)
  978.         Coutput << err.insert8;
  979.     if (err.insert9)
  980.         Coutput << err.insert9;
  981.  
  982.     return;
  983. }
  984.  
  985.  
  986. void SemanticError::PrintINVALID_OPTION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  987. {
  988.     Coutput << '\"'
  989.             << err.insert1
  990.             << "\" is an invalid option; "
  991.             << StringConstant::U8S_command_format
  992.             << '.';
  993.  
  994.     return;
  995. }
  996.  
  997.  
  998. void SemanticError::PrintINVALID_K_OPTION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  999. {
  1000.     Coutput << "No argument specified for +K option. The proper form is \"+Kxxx=xxx\" (with no intervening space).";
  1001.  
  1002.     return;
  1003. }
  1004.  
  1005.  
  1006. void SemanticError::PrintINVALID_K_TARGET(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1007. {
  1008.     Coutput << '\"'
  1009.             << err.insert1
  1010.             << "\" is not a valid target in a +K option. The target must be a numeric type or boolean.";
  1011.  
  1012.     return;
  1013. }
  1014.  
  1015.  
  1016. void SemanticError::PrintINVALID_TAB_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1017. {
  1018.     Coutput << '\"'
  1019.             << err.insert1
  1020.             << "\" is not a valid tab size. An integer value is expected.";
  1021.  
  1022.     return;
  1023. }
  1024.  
  1025.  
  1026. void SemanticError::PrintINVALID_DIRECTORY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1027. {
  1028.     Coutput << "The directory specified in the \"-d\" option, \""
  1029.             << err.insert1
  1030.             << "\", is either invalid or it could not be expanded.";
  1031.  
  1032.     return;
  1033. }
  1034.  
  1035.  
  1036. void SemanticError::PrintUNSUPPORTED_OPTION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1037. {
  1038.     Coutput << "This option \""
  1039.             << err.insert1
  1040.             << "\" is currently unsupported.";
  1041.  
  1042.     return;
  1043. }
  1044.  
  1045.  
  1046. void SemanticError::PrintNO_CURRENT_DIRECTORY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1047. {
  1048.     Coutput << "Could not open current directory.";
  1049.  
  1050.     return;
  1051. }
  1052.  
  1053.  
  1054. void SemanticError::PrintCANNOT_OPEN_ZIP_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1055. {
  1056.     Coutput << "The file \""
  1057.             << err.insert1
  1058.             << "\" is not a valid zip file.";
  1059.  
  1060.     return;
  1061. }
  1062.  
  1063.  
  1064. void SemanticError::PrintCANNOT_OPEN_PATH_DIRECTORY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1065. {
  1066.     Coutput << "The file \""
  1067.             << err.insert1
  1068.             << "\" is not a valid directory.";
  1069.  
  1070.     return;
  1071. }
  1072.  
  1073.  
  1074. void SemanticError::PrintPACKAGE_NOT_FOUND(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1075. {
  1076.     Coutput << "Could not find package named: \n";
  1077.     for (int i = 1; i < control.classpath.Length(); i++)
  1078.     {
  1079.         PathSymbol *path_symbol = control.classpath[i];
  1080.         wchar_t *path = path_symbol -> Name();
  1081.  
  1082.         Coutput << "                "
  1083.                 << path;
  1084.         if (path_symbol -> IsZip())
  1085.         {
  1086.             Coutput << "("
  1087.                     << err.insert1
  1088.                     << ")";
  1089.         }
  1090.         else
  1091.         {
  1092.             Coutput << "/"
  1093.                     << err.insert1;
  1094.         }
  1095.  
  1096.         if (i + 2 < control.classpath.Length())
  1097.              Coutput << ", \n";
  1098.         else if (i + 2 == control.classpath.Length())
  1099.              Coutput << " or \n";
  1100.     }
  1101.  
  1102.     return;
  1103. }
  1104.  
  1105.  
  1106. void SemanticError::PrintCANNOT_OPEN_DIRECTORY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1107. {
  1108.     Coutput << "Unable to open directory \""
  1109.             << err.insert1
  1110.             << "\".";
  1111.  
  1112.     return;
  1113. }
  1114.  
  1115.  
  1116. void SemanticError::PrintBAD_INPUT_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1117. {
  1118.     Coutput << "The input file \""
  1119.             << err.insert1
  1120.             << "\" does not have the \".java\" extension.";
  1121.  
  1122.     return;
  1123. }
  1124.  
  1125.  
  1126. void SemanticError::PrintUNREADABLE_INPUT_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1127. {
  1128.     Coutput << "The input file \""
  1129.             << err.insert1
  1130.             << "\" was not found.";
  1131.  
  1132.     return;
  1133. }
  1134.  
  1135.  
  1136. void SemanticError::PrintNON_STANDARD_LIBRARY_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1137. {
  1138.     Coutput << "A non-standard version of the type \"";
  1139.     if (NotDot(err.insert1))
  1140.     {
  1141.         Coutput << err.insert1
  1142.                 << "/";
  1143.     }
  1144.     Coutput << err.insert2
  1145.             << "\" was found. Class files that depend on this type may not have been generated.";
  1146.  
  1147.     return;
  1148. }
  1149.  
  1150.  
  1151. void SemanticError::PrintLIBRARY_METHOD_NOT_FOUND(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1152. {
  1153.     Coutput << "A class file was not generated for the type \"";
  1154.     if (NotDot(err.insert1))
  1155.     {
  1156.         Coutput << err.insert1
  1157.                 << "/";
  1158.     }
  1159.     Coutput << err.insert2
  1160.             << "\" because a library method that it depends on was not found. See system messages for more information.";
  1161.  
  1162.     return;
  1163. }
  1164.  
  1165.  
  1166. void SemanticError::PrintCANNOT_REOPEN_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1167. {
  1168.     Coutput << "Unable to reopen file \""
  1169.             << err.insert1
  1170.             << "\".";
  1171.  
  1172.     return;
  1173. }
  1174.  
  1175.  
  1176. void SemanticError::PrintCANNOT_WRITE_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1177. {
  1178.     Coutput << "Unable to write file \""
  1179.             << err.insert1
  1180.             << "\".";
  1181.  
  1182.     return;
  1183. }
  1184.  
  1185.  
  1186. void SemanticError::PrintCONSTANT_POOL_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1187. {
  1188.     Coutput << "Processing of this type, \"";
  1189.     if (NotDot(err.insert1))
  1190.     {
  1191.         Coutput << err.insert1
  1192.                 << "/";
  1193.     }
  1194.     Coutput << err.insert2
  1195.             << "\", produced a constant pool that exceeded the limit of 65535 elements.";
  1196.  
  1197.     return;
  1198. }
  1199.  
  1200.  
  1201. void SemanticError::PrintINTERFACES_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1202. {
  1203.     Coutput << "The type \"";
  1204.     if (NotDot(err.insert1))
  1205.     {
  1206.         Coutput << err.insert1
  1207.                 << "/";
  1208.     }
  1209.     Coutput << err.insert2
  1210.             << "\" implements more than 65535 interfaces.";
  1211.  
  1212.     return;
  1213. }
  1214.  
  1215.  
  1216. void SemanticError::PrintMETHODS_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1217. {
  1218.     Coutput << "The type \"";
  1219.     if (NotDot(err.insert1))
  1220.     {
  1221.         Coutput << err.insert1
  1222.                 << "/";
  1223.     }
  1224.     Coutput << err.insert2
  1225.             << "\" contains more than 65535 methods.";
  1226.  
  1227.     return;
  1228. }
  1229.  
  1230.  
  1231. void SemanticError::PrintSTRING_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1232. {
  1233.     Coutput << "The type \"";
  1234.     if (NotDot(err.insert1))
  1235.     {
  1236.         Coutput << err.insert1
  1237.                 << "/";
  1238.     }
  1239.     Coutput << err.insert2
  1240.             << "\" generated one or more strings whose length exceeds the maximum length of 65535 Utf8 chacracters.";
  1241.  
  1242.     return;
  1243. }
  1244.  
  1245.  
  1246. void SemanticError::PrintPARAMETER_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1247. {
  1248.     Coutput << "Method \""
  1249.             << err.insert1
  1250.             << "\" in type \"";
  1251.     if (NotDot(err.insert2))
  1252.     {
  1253.         Coutput << err.insert2
  1254.                 << "/";
  1255.     }
  1256.     Coutput << err.insert3
  1257.             << "\" contains more than 255 formal parameters. Note that a parameter of type long or double counts as 2 parameters.";
  1258.  
  1259.     return;
  1260. }
  1261.  
  1262.  
  1263. void SemanticError::PrintARRAY_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1264. {
  1265.     Coutput << "The number of dimensions in an array is limited to 255.";
  1266.  
  1267.     return;
  1268. }
  1269.  
  1270.  
  1271. void SemanticError::PrintFIELDS_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1272. {
  1273.     Coutput << "The type \"";
  1274.     if (NotDot(err.insert1))
  1275.     {
  1276.         Coutput << err.insert1
  1277.                 << "/";
  1278.     }
  1279.     Coutput << err.insert2
  1280.             << "\" contains more than 65535 fields.";
  1281.  
  1282.     return;
  1283. }
  1284.  
  1285.  
  1286. void SemanticError::PrintLOCAL_VARIABLES_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1287. {
  1288.     Coutput << "Method \""
  1289.             << err.insert1
  1290.             << "\" in type \"";
  1291.     if (NotDot(err.insert2))
  1292.     {
  1293.         Coutput << err.insert2
  1294.                 << "/";
  1295.     }
  1296.     Coutput << err.insert3
  1297.             << "\" contains more than 65535 local variables.";
  1298.  
  1299.     return;
  1300. }
  1301.  
  1302.  
  1303. void SemanticError::PrintSTACK_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1304. {
  1305.     Coutput << "Processing of the method or constructor \""
  1306.             << err.insert1
  1307.             << "\" in type \"";
  1308.     if (NotDot(err.insert2))
  1309.     {
  1310.         Coutput << err.insert2
  1311.                 << "/";
  1312.     }
  1313.     Coutput << err.insert3
  1314.             << "\" requires a stack that exceeds the maximum limit of 65535.";
  1315.  
  1316.     return;
  1317. }
  1318.  
  1319.  
  1320. void SemanticError::PrintCODE_OVERFLOW(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1321. {
  1322.     Coutput << "Processing of the method or constructor \""
  1323.             << err.insert1
  1324.             << "\" in type \"";
  1325.     if (NotDot(err.insert2))
  1326.     {
  1327.         Coutput << err.insert2
  1328.                 << "/";
  1329.     }
  1330.     Coutput << err.insert3
  1331.             << "\" produced a code attribute that exceeds the code limit of 65535 elements.";
  1332.  
  1333.     return;
  1334. }
  1335.  
  1336.  
  1337. void SemanticError::PrintCANNOT_COMPUTE_COLUMNS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1338. {
  1339.     Coutput << "Unable to reopen file \""
  1340.             << err.insert1
  1341.             << "\". Therefore, column positions may be incorrect.";
  1342.  
  1343.     return;
  1344. }
  1345.  
  1346.  
  1347. void SemanticError::PrintREDUNDANT_ABSTRACT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1348. {
  1349.     Coutput << "The use of the \"abstract\" modifier in this context is redundant and strongly discouraged as a matter of style.";
  1350.  
  1351.     return;
  1352. }
  1353.  
  1354.  
  1355. void SemanticError::PrintREDUNDANT_FINAL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1356. {
  1357.     Coutput << "The use of the \"final\" modifier in this context is redundant and strongly discouraged as a matter of style.";
  1358.  
  1359.     return;
  1360. }
  1361.  
  1362.  
  1363. void SemanticError::PrintREDUNDANT_PUBLIC(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1364. {
  1365.     Coutput << "The use of the \"public\" modifier in this context is redundant and strongly discouraged as a matter of style.";
  1366.  
  1367.     return;
  1368. }
  1369.  
  1370.  
  1371. void SemanticError::PrintREDUNDANT_STATIC(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1372. {
  1373.     Coutput << "The use of the \"static\" modifier in this context is redundant and strongly discouraged as a matter of style.";
  1374.  
  1375.     return;
  1376. }
  1377.  
  1378.  
  1379. void SemanticError::PrintEMPTY_DECLARATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1380. {
  1381.     Coutput << "An EmptyDeclaration is a deprecated feature that should not be used - \";\" ignored.";
  1382.  
  1383.     return;
  1384. }
  1385.  
  1386.  
  1387. void SemanticError::PrintOBSOLESCENT_ABSTRACT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1388. {
  1389.     Coutput << "Every interface in implicitly abstract. This modifier is obsolete and should not be used in new Java programs.";
  1390.  
  1391.     return;
  1392. }
  1393.  
  1394.  
  1395. void SemanticError::PrintOBSOLESCENT_BRACKETS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1396. {
  1397.     Coutput << "The use of empty bracket pairs following a MethodDeclarator should not be used in new Java programs.";
  1398.  
  1399.     return;
  1400. }
  1401.  
  1402.  
  1403. void SemanticError::PrintNO_TYPES(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1404. {
  1405.     Coutput << "This compilation unit contains no type declaration.";
  1406.  
  1407.     return;
  1408. }
  1409.  
  1410.  
  1411. void SemanticError::PrintTYPE_IN_MULTIPLE_FILES(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1412. {
  1413.     Coutput << "The file \"";
  1414.     if (NotDot(err.insert1))
  1415.     {
  1416.         Coutput << err.insert1
  1417.                 << "/";
  1418.     }
  1419.     Coutput << err.insert2
  1420.             << ".java\" contains type \""
  1421.             << err.insert4
  1422.             << "\" which conflicts with file \"";
  1423.     if (NotDot(err.insert3))
  1424.     {
  1425.         Coutput << err.insert3
  1426.                 << "/";
  1427.     }
  1428.     Coutput << err.insert4
  1429.             << ".java\".";
  1430.  
  1431.     return;
  1432. }
  1433.  
  1434.  
  1435. void SemanticError::PrintPACKAGE_TYPE_CONFLICT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1436. {
  1437.     Coutput << "The type \"";
  1438.     if (NotDot(err.insert1))
  1439.     {
  1440.         Coutput << err.insert1
  1441.                 << "/";
  1442.     }
  1443.     Coutput << err.insert2
  1444.             << "\" contained in file \""
  1445.             << err.insert3
  1446.             << "\" conflicts with the package \"";
  1447.     if (NotDot(err.insert1))
  1448.     {
  1449.         Coutput << err.insert1
  1450.                 << "/";
  1451.     }
  1452.     Coutput << err.insert2
  1453.             << "\".";
  1454.  
  1455.     return;
  1456. }
  1457.  
  1458.  
  1459. void SemanticError::PrintDIRECTORY_FILE_CONFLICT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1460. {
  1461.     Coutput << "The type \""
  1462.             << err.insert1
  1463.             << "\" contained in file \"";
  1464.     if (NotDot(err.insert2))
  1465.     {
  1466.         Coutput << err.insert2
  1467.                 << "/";
  1468.     }
  1469.     Coutput << err.insert3
  1470.             << ".java\" conflicts with the directory \""
  1471.             << err.insert4
  1472.             << "\".";
  1473.  
  1474.     return;
  1475. }
  1476.  
  1477.  
  1478. void SemanticError::PrintFILE_FILE_CONFLICT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1479. {
  1480.     Coutput << "Cannot write class file \""
  1481.             << err.insert1
  1482.             << ".class\" because that name conflicts with the name of the class file \""
  1483.             << err.insert2
  1484.             << "\" in directory \""
  1485.             << err.insert3
  1486.             << "\". This is illegal because file names are case-insensitive in this system.";
  1487.  
  1488.     return;
  1489. }
  1490.  
  1491.  
  1492. void SemanticError::PrintMULTIPLE_PUBLIC_TYPES(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1493. {
  1494.     Coutput << "The type \""
  1495.             << err.insert1
  1496.             << "\" is declared public in compilation unit \""
  1497.             << lex_stream -> FileName()
  1498.             << "\" which also contains the public type, \""
  1499.             << err.insert2
  1500.             << "\".";
  1501.  
  1502.     return;
  1503. }
  1504.  
  1505.  
  1506. void SemanticError::PrintMISMATCHED_TYPE_AND_FILE_NAMES(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1507. {
  1508.     Coutput << "The public type \""
  1509.             << err.insert1
  1510.             << "\" does not match the name of its containing file \""
  1511.             << lex_stream -> FileName()
  1512.             << "\".";
  1513.  
  1514.     return;
  1515. }
  1516.  
  1517.  
  1518. void SemanticError::PrintREFERENCE_TO_TYPE_IN_MISMATCHED_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1519. {
  1520.     Coutput << "The type \""
  1521.             << err.insert1
  1522.             << "\" is defined in the file \""
  1523.             << err.insert2
  1524.             << ".java\" but referenced in the file \""
  1525.             << lex_stream -> FileName()
  1526.             << "\". It is recommended that it be redefined in \""
  1527.             << err.insert1
  1528.             << ".java\".";
  1529.  
  1530.     return;
  1531. }
  1532.  
  1533.  
  1534. void SemanticError::PrintDUPLICATE_INNER_TYPE_NAME(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1535. {
  1536.     Coutput << "The inner type named \""
  1537.             << err.insert1
  1538.             << "\" is nested in an outer class of the same name at location "
  1539.             << err.insert2
  1540.             << '.';
  1541.  
  1542.     return;
  1543. }
  1544.  
  1545.  
  1546. void SemanticError::PrintDUPLICATE_TYPE_DECLARATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1547. {
  1548.     Coutput << "Duplicate declaration of type \""
  1549.             << err.insert1
  1550.             << "\". The other occurrence is at location "
  1551.             << err.insert2
  1552.             << '.';
  1553.  
  1554.     return;
  1555. }
  1556.  
  1557.  
  1558. void SemanticError::PrintUNNECESSARY_TYPE_IMPORT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1559. {
  1560.     Coutput << "Unnecessary import of type \""
  1561.             << err.insert1
  1562.             << "\". The type is declared at location "
  1563.             << err.insert2
  1564.             << '.';
  1565.  
  1566.     return;
  1567. }
  1568.  
  1569.  
  1570. void SemanticError::PrintUNINITIALIZED_FIELD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1571. {
  1572.     Coutput << "The field \""
  1573.             << err.insert1
  1574.             << "\" is not initialized.";
  1575.  
  1576.     return;
  1577. }
  1578.  
  1579.  
  1580. void SemanticError::PrintDUPLICATE_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1581. {
  1582.     Coutput << "Duplicate specification of this modifier.";
  1583.  
  1584.     return;
  1585. }
  1586.  
  1587.  
  1588. void SemanticError::PrintDUPLICATE_ACCESS_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1589. {
  1590.     Coutput << "Duplicate specification of an access modifier. "
  1591.             "Only one instance of \"public\", \"private\", or \"protected\" may appear in a declaration.";
  1592.  
  1593.     return;
  1594. }
  1595.  
  1596.  
  1597. void SemanticError::PrintINVALID_TOP_LEVEL_CLASS_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1598. {
  1599.     Coutput << err.insert1
  1600.             << " is not a valid modifier for a top-level class.";
  1601.  
  1602.     return;
  1603. }
  1604.  
  1605.  
  1606. void SemanticError::PrintINVALID_INNER_CLASS_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1607. {
  1608.     Coutput << err.insert1
  1609.             << " is not a valid modifier for an inner class.";
  1610.  
  1611.     return;
  1612. }
  1613.  
  1614.  
  1615. void SemanticError::PrintINVALID_STATIC_INNER_CLASS_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1616. {
  1617.     Coutput << err.insert1
  1618.             << " is not a valid modifier for an inner class that is enclosed in an interface.";
  1619.  
  1620.     return;
  1621. }
  1622.  
  1623.  
  1624. void SemanticError::PrintINVALID_LOCAL_CLASS_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1625. {
  1626.     Coutput << err.insert1
  1627.             << " is not a valid modifier for a local inner class.";
  1628.  
  1629.     return;
  1630. }
  1631.  
  1632.  
  1633. void SemanticError::PrintFINAL_ABSTRACT_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1634. {
  1635.     Coutput << "A class may not be declared both \"final\" and \"abstract\".";
  1636.  
  1637.     return;
  1638. }
  1639.  
  1640.  
  1641. void SemanticError::PrintINVALID_INTERFACE_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1642. {
  1643.     Coutput << err.insert1
  1644.             << " is not a valid interface modifier.";
  1645.  
  1646.     return;
  1647. }
  1648.  
  1649.  
  1650. void SemanticError::PrintVOLATILE_FINAL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1651. {
  1652.     Coutput << "A \"volatile\" field may not be declared \"final\".";
  1653.  
  1654.     return;
  1655. }
  1656.  
  1657.  
  1658. void SemanticError::PrintFINAL_VOLATILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1659. {
  1660.     Coutput << "A \"final\" field may not be declared \"volatile\".";
  1661.  
  1662.     return;
  1663. }
  1664.  
  1665.  
  1666. void SemanticError::PrintINVALID_FIELD_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1667. {
  1668.     Coutput << err.insert1
  1669.             << " is not a valid field modifier.";
  1670.  
  1671.     return;
  1672. }
  1673.  
  1674.  
  1675. void SemanticError::PrintINVALID_LOCAL_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1676. {
  1677.     Coutput << err.insert1
  1678.             << " is not a valid local variable or parameter modifier.";
  1679.  
  1680.     return;
  1681. }
  1682.  
  1683.  
  1684. void SemanticError::PrintINVALID_METHOD_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1685. {
  1686.     Coutput << err.insert1
  1687.             << " is not a valid method modifier.";
  1688.  
  1689.     return;
  1690. }
  1691.  
  1692.  
  1693. void SemanticError::PrintINVALID_SIGNATURE_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1694. {
  1695.     Coutput << err.insert1
  1696.             << " is not a valid signature modifier.";
  1697.  
  1698.     return;
  1699. }
  1700.  
  1701.  
  1702. void SemanticError::PrintINVALID_CONSTRUCTOR_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1703. {
  1704.     Coutput << err.insert1
  1705.             << " is not a valid constructor modifier.";
  1706.  
  1707.     return;
  1708. }
  1709.  
  1710.  
  1711. void SemanticError::PrintINVALID_CONSTANT_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1712. {
  1713.     Coutput << err.insert1
  1714.             << " is not a valid constant modifier.";
  1715.  
  1716.     return;
  1717. }
  1718.  
  1719.  
  1720. void SemanticError::PrintPARENT_TYPE_IN_UNNAMED_PACKAGE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1721. {
  1722.     Coutput << "The type associated with this construct is (or depends on) the type ";
  1723.     if (NotDot(err.insert1))
  1724.     {
  1725.         Coutput << err.insert1
  1726.                 << "/";
  1727.     }
  1728.     Coutput << err.insert2
  1729.             << " which is contained in an unnamed package.";
  1730.  
  1731.     return;
  1732. }
  1733.  
  1734.  
  1735. void SemanticError::PrintRECOMPILATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1736. {
  1737.     Coutput << "The type associated with this construct depends on file ";
  1738.     if (NotDot(err.insert1))
  1739.     {
  1740.         Coutput << err.insert1
  1741.                 << "/";
  1742.     }
  1743.     Coutput << err.insert2
  1744.             << ".class which, in turn, depends on file ";
  1745.     if (NotDot(err.insert3))
  1746.     {
  1747.         Coutput << err.insert3
  1748.                 << "/";
  1749.     }
  1750.     Coutput << err.insert4
  1751.             << ".java. All files that depend on this source file, in particular, ";
  1752.     if (NotDot(err.insert1))
  1753.     {
  1754.         Coutput << err.insert1
  1755.                 << "/";
  1756.     }
  1757.     Coutput << err.insert2
  1758.             << ".java should be recompiled.";
  1759.  
  1760.     return;
  1761. }
  1762.  
  1763.  
  1764. void SemanticError::PrintTYPE_NOT_FOUND(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1765. {
  1766.     Coutput << "Type ";
  1767.     if (NotDot(err.insert1))
  1768.     {
  1769.         Coutput << err.insert1
  1770.                 << "/";
  1771.     }
  1772.     Coutput << err.insert2
  1773.             << " was not found.";
  1774.  
  1775.     return;
  1776. }
  1777.  
  1778.  
  1779. void SemanticError::PrintDUPLICATE_ON_DEMAND_IMPORT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1780. {
  1781.     Coutput << "Type "
  1782.             << err.insert1
  1783.             << " is imported on demand from package "
  1784.             << err.insert2
  1785.             << " and package "
  1786.             << err.insert3
  1787.             << '.';
  1788.  
  1789.     return;
  1790. }
  1791.  
  1792.  
  1793. void SemanticError::PrintNOT_A_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1794. {
  1795.     Coutput << "A type is expected here.";
  1796.  
  1797.     return;
  1798. }
  1799.  
  1800.  
  1801. void SemanticError::PrintNOT_A_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1802. {
  1803.     Coutput << "Interface \"";
  1804.     if (NotDot(err.insert1))
  1805.     {
  1806.         Coutput << err.insert1
  1807.                 << '/';
  1808.     }
  1809.     Coutput << err.insert2
  1810.             << "\" cannot be used where a class is expected.";
  1811.  
  1812.     return;
  1813. }
  1814.  
  1815.  
  1816. void SemanticError::PrintNOT_AN_INTERFACE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1817. {
  1818.     Coutput << "Class ";
  1819.     if (NotDot(err.insert1))
  1820.     {
  1821.         Coutput << err.insert1
  1822.                 << '/';
  1823.     }
  1824.     Coutput << err.insert2
  1825.             << " cannot be used where an interface is expected.";
  1826.  
  1827.     return;
  1828. }
  1829.  
  1830.  
  1831. void SemanticError::PrintSUPER_IS_FINAL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1832. {
  1833.     Coutput << "The super class \"";
  1834.     if (NotDot(err.insert1))
  1835.     {
  1836.         Coutput << err.insert1
  1837.                 << '/';
  1838.     }
  1839.     Coutput << err.insert2
  1840.             << "\" is final. A final class must not have subclasses.";
  1841.  
  1842.     return;
  1843. }
  1844.  
  1845.  
  1846. void SemanticError::PrintOBJECT_WITH_SUPER_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1847. {
  1848.     Coutput << "The type "
  1849.             << err.insert1
  1850.             << '/'
  1851.             << err.insert2
  1852.             << " must not have a super type.";
  1853.  
  1854.     return;
  1855. }
  1856.  
  1857.  
  1858. void SemanticError::PrintOBJECT_HAS_NO_SUPER_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1859. {
  1860.     Coutput << "The type "
  1861.             << err.insert1
  1862.             << '/'
  1863.             << err.insert2
  1864.             << " does not have a super type.";
  1865.  
  1866.     return;
  1867. }
  1868.  
  1869.  
  1870. void SemanticError::PrintDUPLICATE_FIELD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1871. {
  1872.     Coutput << "Duplicate declaration of field \""
  1873.             << err.insert1
  1874.             << "\" in type \""
  1875.             << err.insert2
  1876.             << "\".";
  1877.  
  1878.     return;
  1879. }
  1880.  
  1881.  
  1882. void SemanticError::PrintDUPLICATE_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1883. {
  1884.     Coutput << "Duplicate declaration of method \""
  1885.             << err.insert1
  1886.             << "\" in type \""
  1887.             << err.insert2
  1888.             << "\".";
  1889.  
  1890.     return;
  1891. }
  1892.  
  1893.  
  1894. void SemanticError::PrintMISMATCHED_INHERITED_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1895. {
  1896.     Coutput << "The return type of method \""
  1897.             << err.insert1
  1898.             << "\" does not match the return type of method \""
  1899.             << err.insert2
  1900.             << "\" inherited from type \"";
  1901.     if (NotDot(err.insert3))
  1902.     {
  1903.         Coutput << err.insert3
  1904.                 << "/";
  1905.     }
  1906.     Coutput << err.insert4
  1907.             << "\".";
  1908.  
  1909.     return;
  1910. }
  1911.  
  1912.  
  1913. void SemanticError::PrintMISMATCHED_INHERITED_METHOD_EXTERNALLY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1914. {
  1915.     Coutput << "In class \""
  1916.             << err.insert1
  1917.             << "\", the method \""
  1918.             << err.insert2
  1919.             << "\", inherited from type \"";
  1920.     if (NotDot(err.insert3))
  1921.     {
  1922.         Coutput << err.insert3
  1923.                 << "/";
  1924.     }
  1925.     Coutput << err.insert4
  1926.             << "\", does not have the same return type as the overridden method \""
  1927.             << err.insert5
  1928.             << "\", inherited from type \"";
  1929.     if (NotDot(err.insert6))
  1930.     {
  1931.         Coutput << err.insert6
  1932.                 << "/";
  1933.     }
  1934.     Coutput << err.insert7
  1935.             << "\".";
  1936.  
  1937.     return;
  1938. }
  1939.  
  1940.  
  1941. void SemanticError::PrintDUPLICATE_CONSTRUCTOR(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1942. {
  1943.     Coutput << "Duplicate declaration of this constructor in type \""
  1944.             << err.insert1
  1945.             << "\".";
  1946.  
  1947.     return;
  1948. }
  1949.  
  1950.  
  1951. void SemanticError::PrintMISMATCHED_CONSTRUCTOR_NAME(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1952. {
  1953.     Coutput << "The name of the constructor \""
  1954.             << err.insert1
  1955.             << "\" does not match the name of the class \""
  1956.             << err.insert2
  1957.             << "\".";
  1958.  
  1959.     return;
  1960. }
  1961.  
  1962.  
  1963. void SemanticError::PrintMETHOD_WITH_CONSTRUCTOR_NAME(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1964. {
  1965.     Coutput << "The name of this method \""
  1966.             << err.insert1
  1967.             << "\" matches the name of the containing class. "
  1968.                "However, the method is not a constructor since its declarator is qualified with a type.";
  1969.  
  1970.     return;
  1971. }
  1972.  
  1973.  
  1974. void SemanticError::PrintDUPLICATE_FORMAL_PARAMETER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1975. {
  1976.     Coutput << "Duplicate declaration of formal parameter "
  1977.             << err.insert1
  1978.             << '.';
  1979.  
  1980.     return;
  1981. }
  1982.  
  1983.  
  1984. void SemanticError::PrintDUPLICATE_LOCAL_VARIABLE_DECLARATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1985. {
  1986.     Coutput << "Duplicate declaration of local variable \""
  1987.             << err.insert1
  1988.             << "\".";
  1989.  
  1990.     return;
  1991. }
  1992.  
  1993.  
  1994. void SemanticError::PrintDUPLICATE_LOCAL_TYPE_DECLARATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  1995. {
  1996.     Coutput << "Duplicate declaration of local class \""
  1997.             << err.insert1
  1998.             << "\". The other occurrence is at location "
  1999.             << err.insert2
  2000.             << '.';
  2001.  
  2002.     return;
  2003. }
  2004.  
  2005.  
  2006. void SemanticError::PrintMULTIPLE_DEFAULT_LABEL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2007. {
  2008.     Coutput << "Multiple specification of default label in switch statement.";
  2009.  
  2010.     return;
  2011. }
  2012.  
  2013.  
  2014. void SemanticError::PrintUNDECLARED_LABEL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2015. {
  2016.     Coutput << err.insert1
  2017.             << " is an undeclared label.";
  2018.  
  2019.     return;
  2020. }
  2021.  
  2022.  
  2023. void SemanticError::PrintDUPLICATE_LABEL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2024. {
  2025.     Coutput << "Duplicate declaration of label \""
  2026.             << err.insert1
  2027.             << "\".";
  2028.  
  2029.     return;
  2030. }
  2031.  
  2032.  
  2033. void SemanticError::PrintTYPE_NOT_THROWABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2034. {
  2035.     Coutput << "The type \"";
  2036.     if (NotDot(err.insert1))
  2037.     {
  2038.         Coutput << err.insert1
  2039.                 << "/";
  2040.     }
  2041.     Coutput << err.insert2
  2042.             << "\" is not a subclass of \"Throwable\".";
  2043.  
  2044.     return;
  2045. }
  2046.  
  2047.  
  2048. void SemanticError::PrintCATCH_PRIMITIVE_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2049. {
  2050.     Coutput << "A primitive type cannot be used to declare a catch clause parameter - the type Error is assumed.";
  2051.  
  2052.     return;
  2053. }
  2054.  
  2055.  
  2056. void SemanticError::PrintCATCH_ARRAY_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2057. {
  2058.     Coutput << "A array type cannot be used to declare a catch clause parameter - the type Error is assumed.";
  2059.  
  2060.     return;
  2061. }
  2062.  
  2063.  
  2064. void SemanticError::PrintAMBIGUOUS_FIELD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2065. {
  2066.     Coutput << "The field name \""
  2067.             << err.insert1
  2068.             << "\" is an ambiguous name found in the types \"";
  2069.     if (NotDot(err.insert2))
  2070.     {
  2071.         Coutput << err.insert2
  2072.                 << "/";
  2073.     }
  2074.     Coutput << err.insert3
  2075.             << "\" and \"";
  2076.     if (NotDot(err.insert4))
  2077.     {
  2078.         Coutput << err.insert4
  2079.                 << "/";
  2080.     }
  2081.     Coutput << err.insert5
  2082.             << "\".";
  2083.  
  2084.     return;
  2085. }
  2086.  
  2087.  
  2088. void SemanticError::PrintAMBIGUOUS_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2089. {
  2090.     Coutput << "The the nested type name \""
  2091.             << err.insert1
  2092.             << "\" is an ambiguous name found in the types \"";
  2093.     if (NotDot(err.insert2))
  2094.     {
  2095.         Coutput << err.insert2
  2096.                 << "/";
  2097.     }
  2098.     Coutput << err.insert3
  2099.             << "\" and \"";
  2100.     if (NotDot(err.insert4))
  2101.     {
  2102.         Coutput << err.insert4
  2103.                 << "/";
  2104.     }
  2105.     Coutput << err.insert5
  2106.             << "\".";
  2107.  
  2108.     return;
  2109. }
  2110.  
  2111.  
  2112. void SemanticError::PrintFIELD_IS_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2113. {
  2114.     Coutput << "The name \""
  2115.             << err.insert1
  2116.             << "\" cannot be dereferenced as it represents a type.";
  2117.  
  2118.     return;
  2119. }
  2120.  
  2121.  
  2122. void SemanticError::PrintFIELD_NOT_FOUND(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2123. {
  2124.     Coutput << "No field named \""
  2125.             << err.insert1
  2126.             << "\" was found in type \"";
  2127.     if (NotDot(err.insert2))
  2128.     {
  2129.         Coutput << err.insert2
  2130.                 << "/";
  2131.     }
  2132.     Coutput << err.insert3
  2133.             << "\".";
  2134.  
  2135.     return;
  2136. }
  2137.  
  2138.  
  2139. void SemanticError::PrintFIELD_NAME_MISSPELLED(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2140. {
  2141.     Coutput << "No field named \""
  2142.             << err.insert1
  2143.             << "\" was found in type \"";
  2144.     if (NotDot(err.insert2))
  2145.     {
  2146.         Coutput << err.insert2
  2147.                 << "/";
  2148.     }
  2149.     Coutput << err.insert3
  2150.             << "\". However, there is an accessible field \""
  2151.             << err.insert4
  2152.             << "\" whose name closely matches the name \""
  2153.             << err.insert1
  2154.             << "\".";
  2155.  
  2156.     return;
  2157. }
  2158.  
  2159.  
  2160. void SemanticError::PrintFIELD_WITH_PRIVATE_ACCESS_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2161. {
  2162.     Coutput << "The field \""
  2163.             << err.insert1
  2164.             << "\" contained in class \"";
  2165.     if (NotDot(err.insert2))
  2166.     {
  2167.         Coutput << err.insert2
  2168.                 << "/";
  2169.     }
  2170.     Coutput << err.insert3
  2171.             << "\" has private access. Therefore, it is not accessible in class \"";
  2172.     if (NotDot(err.insert4))
  2173.     {
  2174.         Coutput << err.insert4
  2175.                 << "/";
  2176.     }
  2177.     Coutput << err.insert5
  2178.             << "\".";
  2179.  
  2180.     return;
  2181. }
  2182.  
  2183.  
  2184. void SemanticError::PrintFIELD_WITH_DEFAULT_ACCESS_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2185. {
  2186.     Coutput << "The field \""
  2187.             << err.insert1
  2188.             << "\" contained in class \"";
  2189.     if (NotDot(err.insert2))
  2190.     {
  2191.         Coutput << err.insert2
  2192.                 << "/";
  2193.     }
  2194.     Coutput << err.insert3
  2195.             << "\" has default access. Therefore, it is not accessible in class \"";
  2196.     if (NotDot(err.insert4))
  2197.     {
  2198.         Coutput << err.insert4
  2199.                 << "/";
  2200.     }
  2201.     Coutput << err.insert5
  2202.             << "\" which is in a different package.";
  2203.  
  2204.     return;
  2205. }
  2206.  
  2207.  
  2208. void SemanticError::PrintNAME_NOT_FOUND(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2209. {
  2210.     Coutput << "No entity named \""
  2211.             << err.insert1
  2212.             << "\" was found in this environment.";
  2213.  
  2214.     return;
  2215. }
  2216.  
  2217.  
  2218. void SemanticError::PrintNAME_NOT_YET_AVAILABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2219. {
  2220.     Coutput << "Illegal use of name \""
  2221.             << err.insert1
  2222.             << "\" which has not yet been fully declared at this point.";
  2223.  
  2224.     return;
  2225. }
  2226.  
  2227.  
  2228. void SemanticError::PrintNAME_NOT_VARIABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2229. {
  2230.     Coutput << "The name \""
  2231.             << err.insert1
  2232.             << "\" does not denote a valid variable. If \""
  2233.             << err.insert1
  2234.             << "\" is a method that takes no argument, it must be followed by \"()\".";
  2235.  
  2236.     return;
  2237. }
  2238.  
  2239.  
  2240. void SemanticError::PrintMETHOD_NOT_FOUND(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2241. {
  2242.     Coutput << "No match was found for method \""
  2243.             << err.insert1
  2244.             << "\".";
  2245.  
  2246.     return;
  2247. }
  2248.  
  2249.  
  2250. void SemanticError::PrintMETHOD_NAME_NOT_FOUND_IN_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2251. {
  2252.     Coutput << "No method named \""
  2253.             << err.insert1
  2254.             << "\" was found in type \"";
  2255.     if (NotDot(err.insert2))
  2256.     {
  2257.         Coutput << err.insert2
  2258.                 << "/";
  2259.     }
  2260.     Coutput << err.insert3
  2261.             << "\".";
  2262.  
  2263.     return;
  2264. }
  2265.  
  2266.  
  2267. void SemanticError::PrintMETHOD_NAME_MISSPELLED(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2268. {
  2269.     Coutput << "No method named \""
  2270.             << err.insert1
  2271.             << "\" was found in type \"";
  2272.     if (NotDot(err.insert2))
  2273.     {
  2274.         Coutput << err.insert2
  2275.                 << "/";
  2276.     }
  2277.     Coutput << err.insert3
  2278.             << "\". However, there is an accessible method \""
  2279.             << err.insert4
  2280.             << "\" whose name closely matches the name \""
  2281.             << err.insert1
  2282.             << "\".";
  2283.  
  2284.     return;
  2285. }
  2286.  
  2287.  
  2288. void SemanticError::PrintMETHOD_WITH_PRIVATE_ACCESS_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2289. {
  2290.     Coutput << "Method \""
  2291.             << err.insert1
  2292.             << "\" in class \"";
  2293.     if (NotDot(err.insert2))
  2294.     {
  2295.         Coutput << err.insert2
  2296.                 << "/";
  2297.     }
  2298.     Coutput << err.insert3
  2299.             << "\" has private access. Therefore, it is not accessible in class \"";
  2300.     if (NotDot(err.insert4))
  2301.     {
  2302.         Coutput << err.insert4
  2303.                 << "/";
  2304.     }
  2305.     Coutput << err.insert5
  2306.             << "\".";
  2307.  
  2308.     return;
  2309. }
  2310.  
  2311.  
  2312. void SemanticError::PrintMETHOD_WITH_DEFAULT_ACCESS_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2313. {
  2314.     Coutput << "Method \""
  2315.             << err.insert1
  2316.             << "\" in class \"";
  2317.     if (NotDot(err.insert2))
  2318.     {
  2319.         Coutput << err.insert2
  2320.                 << "/";
  2321.     }
  2322.     Coutput << err.insert3
  2323.             << "\" has protected or default access. Therefore, it is not accessible in class \"";
  2324.     if (NotDot(err.insert4))
  2325.     {
  2326.         Coutput << err.insert4
  2327.                 << "/";
  2328.     }
  2329.     Coutput << err.insert5
  2330.             << "\" which is in a different package.";
  2331.  
  2332.     return;
  2333. }
  2334.  
  2335.  
  2336. void SemanticError::PrintHIDDEN_METHOD_IN_ENCLOSING_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2337. {
  2338.     Coutput << "The method \""
  2339.             << err.insert1
  2340.             << "\" contained in the enclosing type \"";
  2341.     if (NotDot(err.insert2))
  2342.     {
  2343.         Coutput << err.insert2
  2344.                 << "/";
  2345.     }
  2346.     Coutput << err.insert3
  2347.             << "\" is a perfect match for this method call."
  2348.                " However, it is not visible in this nested class because a method with the same name is hiding it.";
  2349.  
  2350.     return;
  2351. }
  2352.  
  2353.  
  2354. void SemanticError::PrintFIELD_NOT_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2355. {
  2356.     Coutput << "The name \""
  2357.             << err.insert1
  2358.             << "\" is not a method name but the name of a field member of the type \"";
  2359.     if (NotDot(err.insert2))
  2360.     {
  2361.         Coutput << err.insert2
  2362.                 << "/";
  2363.     }
  2364.     Coutput << err.insert3
  2365.             << "\".";
  2366.  
  2367.     return;
  2368. }
  2369.  
  2370.  
  2371. void SemanticError::PrintTYPE_NOT_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2372. {
  2373.     Coutput << "The keyword \"new\" is expected before this name, \""
  2374.             << err.insert1
  2375.             << "\", as it is not the name of a method but the name of a type.";
  2376.  
  2377.     return;
  2378. }
  2379.  
  2380.  
  2381. void SemanticError::PrintTYPE_NOT_FIELD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2382. {
  2383.     Coutput << "A type \""
  2384.             << err.insert1
  2385.             << "\" was found where a field name or method call was expected. Did you mean to write \""
  2386.             << err.insert1
  2387.             << ".xxx\", or \"new "
  2388.             << err.insert1
  2389.             << "()\", or ... ?";
  2390.  
  2391.     return;
  2392. }
  2393.  
  2394.  
  2395. void SemanticError::PrintMETHOD_NOT_FIELD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2396. {
  2397.     Coutput << "The name \""
  2398.             << err.insert1
  2399.             << "\" is not a field name but the name of a method declared in the type \"";
  2400.     if (NotDot(err.insert2))
  2401.     {
  2402.         Coutput << err.insert2
  2403.                 << "/";
  2404.     }
  2405.     Coutput << err.insert3
  2406.             << "\".";
  2407.  
  2408.     return;
  2409. }
  2410.  
  2411.  
  2412. void SemanticError::PrintAMBIGUOUS_CONSTRUCTOR_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2413. {
  2414.     Coutput << "Ambiguous invocation of constructor \""
  2415.             << err.insert1
  2416.             << "\".";
  2417.  
  2418.     return;
  2419. }
  2420.  
  2421.  
  2422. void SemanticError::PrintAMBIGUOUS_METHOD_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2423. {
  2424.     Coutput << "Ambiguous invocation of method \""
  2425.             << err.insert1
  2426.             << "\". At least two methods are accessible from here: Method \""
  2427.             << err.insert2
  2428.             << "\" declared in type \"";
  2429.     if (NotDot(err.insert3))
  2430.     {
  2431.         Coutput << err.insert3
  2432.                 << '/';
  2433.     }
  2434.     Coutput << err.insert4
  2435.             << "\" and method \""
  2436.             << err.insert5
  2437.             << "\" declared in type \"";
  2438.     if (NotDot(err.insert6))
  2439.     {
  2440.         Coutput << err.insert6
  2441.                 << '/';
  2442.     }
  2443.     Coutput << err.insert7
  2444.             << "\".";
  2445.  
  2446.     return;
  2447. }
  2448.  
  2449.  
  2450. void SemanticError::PrintNAME_NOT_CLASS_VARIABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2451. {
  2452.     Coutput << "The name \""
  2453.             << err.insert1
  2454.             << "\" does not denote a class (static) variable.";
  2455.  
  2456.     return;
  2457. }
  2458.  
  2459.  
  2460. void SemanticError::PrintNOT_A_NUMERIC_VARIABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2461. {
  2462.     Coutput << "Only a variable of numeric type can appear in this context.";
  2463.  
  2464.     return;
  2465. }
  2466.  
  2467.  
  2468. void SemanticError::PrintMETHOD_NOT_CLASS_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2469. {
  2470.     Coutput << "The method \""
  2471.             << err.insert1
  2472.             << "\" does not denote a class method.";
  2473.  
  2474.     return;
  2475. }
  2476.  
  2477.  
  2478. void SemanticError::PrintABSTRACT_TYPE_CREATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2479. {
  2480.     Coutput << "Attempt to instantiate an abstract class \""
  2481.             << err.insert1
  2482.             << "\".";
  2483.  
  2484.     return;
  2485. }
  2486.  
  2487.  
  2488. void SemanticError::PrintCONSTRUCTOR_NOT_FOUND(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2489. {
  2490.     Coutput << "No match was found for constructor \""
  2491.             << err.insert1
  2492.             << "\".";
  2493.  
  2494.     return;
  2495. }
  2496.  
  2497.  
  2498. void SemanticError::PrintMETHOD_FOUND_FOR_CONSTRUCTOR(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2499. {
  2500.     Coutput << "No match was found for constructor \""
  2501.             << err.insert1
  2502.             << "\". However, a method with the same name was found at location "
  2503.             << err.insert2
  2504.             << '.';
  2505.  
  2506.     return;
  2507. }
  2508.  
  2509.  
  2510. void SemanticError::PrintINCOMPATIBLE_TYPE_FOR_INITIALIZATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2511. {
  2512.     Coutput << "The type of the left-hand side (or array type) in this initialization (or array creation expression), \"";
  2513.     if (NotDot(err.insert1))
  2514.     {
  2515.         Coutput << err.insert1
  2516.                 << '/';
  2517.     }
  2518.     Coutput << err.insert2
  2519.             << "\", is not compatible with the type of the right-hand side expression, \"";
  2520.     if (NotDot(err.insert3))
  2521.     {
  2522.         Coutput << err.insert3
  2523.                 << '/';
  2524.     }
  2525.     Coutput << err.insert4
  2526.             << "\".";
  2527.  
  2528.     return;
  2529. }
  2530.  
  2531.  
  2532. void SemanticError::PrintINCOMPATIBLE_TYPE_FOR_ASSIGNMENT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2533. {
  2534.     Coutput << "The type of the left-hand side in this assignment, \"";
  2535.     if (NotDot(err.insert1))
  2536.     {
  2537.         Coutput << err.insert1
  2538.                 << '/';
  2539.     }
  2540.     Coutput << err.insert2
  2541.             << "\", is not compatible with the type of the right-hand side expression, \"";
  2542.     if (NotDot(err.insert3))
  2543.     {
  2544.         Coutput << err.insert3
  2545.                 << '/';
  2546.     }
  2547.     Coutput << err.insert4
  2548.             << "\".";
  2549.  
  2550.     return;
  2551. }
  2552.  
  2553.  
  2554. void SemanticError::PrintINCOMPATIBLE_TYPE_FOR_CONDITIONAL_EXPRESSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2555. {
  2556.     Coutput << "In this conditional expression, the type of the false subexpression, \"";
  2557.     if (NotDot(err.insert1))
  2558.     {
  2559.         Coutput << err.insert1
  2560.                 << '/';
  2561.     }
  2562.     Coutput << err.insert2
  2563.             << "\", is not compatible with the type of the true subexpression, \"";
  2564.     if (NotDot(err.insert3))
  2565.     {
  2566.         Coutput << err.insert3
  2567.                 << '/';
  2568.     }
  2569.     Coutput << err.insert4
  2570.             << "\".";
  2571.  
  2572.     return;
  2573. }
  2574.  
  2575.  
  2576. void SemanticError::PrintVOID_ARRAY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2577. {
  2578.     Coutput << "Arrays of type \"void\" are not legal.";
  2579.  
  2580.     return;
  2581. }
  2582.  
  2583.  
  2584. void SemanticError::PrintVOID_TYPE_IN_EQUALITY_EXPRESSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2585. {
  2586.     Coutput << "Subexpressions of type \"void\" may not appear in an EqualityExpression.";
  2587.  
  2588.     return;
  2589. }
  2590.  
  2591.  
  2592. void SemanticError::PrintINCOMPATIBLE_TYPE_FOR_BINARY_EXPRESSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2593. {
  2594.     Coutput << "The type of the left-hand side expression, \"";
  2595.     if (NotDot(err.insert1))
  2596.     {
  2597.         Coutput << err.insert1
  2598.                 << '/';
  2599.     }
  2600.     Coutput << err.insert2
  2601.             << "\", is not compatible with the type of the right-hand side expression, \"";
  2602.     if (NotDot(err.insert3))
  2603.     {
  2604.         Coutput << err.insert3
  2605.                 << '/';
  2606.     }
  2607.     Coutput << err.insert4
  2608.             << "\" (and vice-versa).";
  2609.  
  2610.     return;
  2611. }
  2612.  
  2613.  
  2614. void SemanticError::PrintINVALID_INSTANCEOF_CONVERSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2615. {
  2616.     Coutput << "The type of the left-side expression, \"";
  2617.     if (NotDot(err.insert1))
  2618.     {
  2619.         Coutput << err.insert1
  2620.                 << '/';
  2621.     }
  2622.     Coutput << err.insert2
  2623.             << "\", cannot possibly be an instance of type \"";
  2624.     if (NotDot(err.insert3))
  2625.     {
  2626.         Coutput << err.insert3
  2627.                 << '/';
  2628.     }
  2629.     Coutput << err.insert4
  2630.             << "\".";
  2631.  
  2632.     return;
  2633. }
  2634.  
  2635.  
  2636. void SemanticError::PrintINVALID_CAST_CONVERSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2637. {
  2638.     Coutput << "An expression of type \""
  2639.             << err.insert1
  2640.             << "\" cannot be cast into type \""
  2641.             << err.insert2
  2642.             << "\".";
  2643.  
  2644.     return;
  2645. }
  2646.  
  2647.  
  2648. void SemanticError::PrintINVALID_CAST_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2649. {
  2650.     Coutput << "Expression found where a type is expected.";
  2651.  
  2652.     return;
  2653. }
  2654.  
  2655.  
  2656. void SemanticError::PrintTYPE_NOT_PRIMITIVE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2657. {
  2658.     Coutput << "The type of this expression, \""
  2659.             << err.insert1
  2660.             << "\", is not a primitive type.";
  2661.  
  2662.     return;
  2663. }
  2664.  
  2665.  
  2666. void SemanticError::PrintTYPE_NOT_INTEGRAL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2667. {
  2668.     Coutput << "The type of this expression, \""
  2669.             << err.insert1
  2670.             << "\", is not an integral type.";
  2671.  
  2672.     return;
  2673. }
  2674.  
  2675.  
  2676. void SemanticError::PrintTYPE_NOT_NUMERIC(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2677. {
  2678.     Coutput << "The type of this expression, \""
  2679.             << err.insert1
  2680.             << "\", is not numeric.";
  2681.  
  2682.     return;
  2683. }
  2684.  
  2685.  
  2686. void SemanticError::PrintTYPE_NOT_INTEGER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2687. {
  2688.     Coutput << "The type of this expression, \""
  2689.             << err.insert1
  2690.             << "\", cannot be promoted to \"int\" by widening conversion.";
  2691.  
  2692.     return;
  2693. }
  2694.  
  2695.  
  2696. void SemanticError::PrintTYPE_NOT_BOOLEAN(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2697. {
  2698.     Coutput << "The type of this expression, \""
  2699.             << err.insert1
  2700.             << "\", is not boolean.";
  2701.  
  2702.     return;
  2703. }
  2704.  
  2705.  
  2706. void SemanticError::PrintTYPE_NOT_ARRAY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2707. {
  2708.     Coutput << "The type of this expression, \""
  2709.             << err.insert1
  2710.             << "\", is not an array type.";
  2711.  
  2712.     return;
  2713. }
  2714.  
  2715.  
  2716. void SemanticError::PrintTYPE_NOT_REFERENCE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2717. {
  2718.     Coutput << "The type of this expression, \""
  2719.             << err.insert1
  2720.             << "\", is not a valid reference type in this context.";
  2721.  
  2722.     return;
  2723. }
  2724.  
  2725.  
  2726. void SemanticError::PrintTYPE_NOT_VALID_FOR_SWITCH(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2727. {
  2728.     Coutput << "The type of a switch statement expression must be either \"int\", \"short\", \"char\" or \"byte\"."
  2729.             << " The type of this expression is \"";
  2730.     if (NotDot(err.insert1))
  2731.     {
  2732.         Coutput << err.insert1
  2733.                 << '/';
  2734.     }
  2735.     Coutput << err.insert2
  2736.             << "\".";
  2737.  
  2738.     return;
  2739. }
  2740.  
  2741.  
  2742. void SemanticError::PrintTYPE_IS_VOID(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2743. {
  2744.     Coutput << "An expression of type \""
  2745.             << err.insert1
  2746.             << "\" is not valid in this context.";
  2747.  
  2748.     return;
  2749. }
  2750.  
  2751.  
  2752. void SemanticError::PrintVALUE_NOT_REPRESENTABLE_IN_SWITCH_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2753. {
  2754.     Coutput << "The value of this expression, "
  2755.             << err.insert1
  2756.             << ", cannot be represented in the type of the switch statement expression, \""
  2757.             << err.insert2
  2758.             << "\".";
  2759.  
  2760.     return;
  2761. }
  2762.  
  2763.  
  2764. void SemanticError::PrintTYPE_NOT_CONVERTIBLE_TO_SWITCH_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2765. {
  2766.     Coutput << "The type of this expression, \""
  2767.             << err.insert1
  2768.             << "\", is not assignment-convertible to the type of the switch statement expression, \""
  2769.             << err.insert2
  2770.             << "\".";
  2771.  
  2772.     return;
  2773. }
  2774.  
  2775.  
  2776. void SemanticError::PrintDUPLICATE_CASE_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2777. {
  2778.     Coutput << "The value of this expression, "
  2779.             << err.insert1
  2780.             << ", has already been used in this switch statement.";
  2781.  
  2782.     return;
  2783. }
  2784.  
  2785.  
  2786. void SemanticError::PrintMISPLACED_THIS_EXPRESSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2787. {
  2788.     Coutput << "A \"this\" expression may only be used in the body of an instance method, "
  2789.                "constructor (after the explicit constructor invocation, if any), "
  2790.                "initializer block, or in the initializer expression of an instance variable.";
  2791.  
  2792.     return;
  2793. }
  2794.  
  2795.  
  2796. void SemanticError::PrintMISPLACED_SUPER_EXPRESSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2797. {
  2798.     Coutput << "A \"super\" expression may only appear in the body of a class that has a super class and"
  2799.                " it must be enclosed in the body of an instance method or constructor or in the initializer"
  2800.                " of an instance variable.";
  2801.  
  2802.     return;
  2803. }
  2804.  
  2805.  
  2806. void SemanticError::PrintFINAL_VARIABLE_TARGET_IN_LOOP(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2807. {
  2808.     Coutput << "Possible attempt to assign a value to a final variable \""
  2809.             << err.insert1
  2810.             << "\""
  2811.             << ", within the body of a loop that may execute more than once.";
  2812.  
  2813.     return;
  2814. }
  2815.  
  2816.  
  2817. void SemanticError::PrintTARGET_VARIABLE_IS_FINAL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2818. {
  2819.     Coutput << "Possible attempt to reassign a value to the final variable \""
  2820.             << err.insert1
  2821.             << "\"";
  2822.     if (err.insert2)
  2823.     {
  2824.         Coutput << ". The other assignement was at location "
  2825.                 << err.insert2;
  2826.     }
  2827.     Coutput << '.';
  2828.  
  2829.     return;
  2830. }
  2831.  
  2832.  
  2833. void SemanticError::PrintUNINITIALIZED_FINAL_VARIABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2834. {
  2835.     Coutput << "A final variable must be initialized.";
  2836.  
  2837.     return;
  2838. }
  2839.  
  2840.  
  2841. void SemanticError::PrintUNINITIALIZED_STATIC_FINAL_VARIABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2842. {
  2843.     Coutput << "A blank class final variable must be initialized in a static initializer block. "
  2844.                "We will assume that it has been initialized to avoid emitting spurious messages.";
  2845.  
  2846.     return;
  2847. }
  2848.  
  2849.  
  2850. void SemanticError::PrintUNINITIALIZED_FINAL_VARIABLE_IN_CONSTRUCTOR(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2851. {
  2852.     Coutput << "The blank final field \"this."
  2853.             << err.insert1
  2854.             << "\" is not definitely assigned a value in this constructor.";
  2855.  
  2856.     return;
  2857. }
  2858.  
  2859.  
  2860. void SemanticError::PrintINIT_SCALAR_WITH_ARRAY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2861. {
  2862.     Coutput << "An array initializer cannot be used to initialize a variable of type \""
  2863.             << err.insert1
  2864.             << "\".";
  2865.  
  2866.     return;
  2867. }
  2868.  
  2869.  
  2870. void SemanticError::PrintINIT_ARRAY_WITH_SCALAR(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2871. {
  2872.     Coutput << "A single expression cannot be used to initialize an array variable of type \""
  2873.             << err.insert1
  2874.             << "\".";
  2875.  
  2876.     return;
  2877. }
  2878.  
  2879.  
  2880. void SemanticError::PrintINVALID_BYTE_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2881. {
  2882.     Coutput << "A byte value must be an integer value (note that a character literal is not an integer value) in the range -128..127.";
  2883.  
  2884.     return;
  2885. }
  2886.  
  2887.  
  2888. void SemanticError::PrintINVALID_SHORT_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2889. {
  2890.     Coutput << "A short value must be an integer value (note that a character literal is not an integer value) "
  2891.                "in the range -32768..32767.";
  2892.  
  2893.     return;
  2894. }
  2895.  
  2896.  
  2897. void SemanticError::PrintINVALID_CHARACTER_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2898. {
  2899.     Coutput << "A character literal must be a valid unicode value - i.e., a character literal enclosed in single quotes or "
  2900.                "an integer value in the range 0..65535 or an escaped 3-digit octal value in the range \\000..\\377.";
  2901.  
  2902.     return;
  2903. }
  2904.  
  2905.  
  2906. void SemanticError::PrintINVALID_INT_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2907. {
  2908.     Coutput << "The value of an \"int\" literal must be a decimal value in the range -2147483648..2147483647"
  2909.                " or a hexadecimal or octal literal that fits in 32 bits.";
  2910.  
  2911.     return;
  2912. }
  2913.  
  2914.  
  2915. void SemanticError::PrintINVALID_LONG_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2916. {
  2917.     Coutput << "The value of a long literal must be a decimal value in the range "
  2918.                "-9223372036854775808..9223372036854775807 or a hexadecimal or octal literal that fits in 64 bits.";
  2919.  
  2920.     return;
  2921. }
  2922.  
  2923.  
  2924. void SemanticError::PrintINVALID_FLOAT_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2925. {
  2926.     Coutput << "Invalid floating-point constant.";
  2927.  
  2928.     return;
  2929. }
  2930.  
  2931.  
  2932. void SemanticError::PrintINVALID_DOUBLE_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2933. {
  2934.     Coutput << "Invalid double constant.";
  2935.  
  2936.     return;
  2937. }
  2938.  
  2939.  
  2940. void SemanticError::PrintINVALID_STRING_VALUE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2941. {
  2942.     Coutput << "The value of this \"String\" literal is invalid. Perhaps it contains a bad escape sequence?";
  2943.  
  2944.     return;
  2945. }
  2946.  
  2947.  
  2948. void SemanticError::PrintRETURN_STATEMENT_IN_INITIALIZER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2949. {
  2950.     Coutput << "A return statement may not appear in an initializer block.";
  2951.  
  2952.     return;
  2953. }
  2954.  
  2955.  
  2956. void SemanticError::PrintMISPLACED_RETURN_WITH_EXPRESSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2957. {
  2958.     Coutput << "A return statement with expression must be contained in a method declaration that is "
  2959.                "declared to return a value.";
  2960.  
  2961.     return;
  2962. }
  2963.  
  2964.  
  2965. void SemanticError::PrintMISPLACED_RETURN_WITH_NO_EXPRESSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2966. {
  2967.     Coutput << "A return statement with no expression may only appear in void method or a constructor.";
  2968.  
  2969.     return;
  2970. }
  2971.  
  2972.  
  2973. void SemanticError::PrintMISMATCHED_RETURN_AND_METHOD_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2974. {
  2975.     Coutput << "The type of this return expression, \"";
  2976.     if (NotDot(err.insert1))
  2977.     {
  2978.         Coutput << err.insert1
  2979.                 << '/';
  2980.     }
  2981.     Coutput << err.insert2
  2982.             << "\", does not match the return type of the method, \"";
  2983.     if (NotDot(err.insert3))
  2984.     {
  2985.         Coutput << err.insert3
  2986.                 << '/';
  2987.     }
  2988.     Coutput << err.insert4
  2989.             << "\".";
  2990.  
  2991.     return;
  2992. }
  2993.  
  2994.  
  2995. void SemanticError::PrintEXPRESSION_NOT_THROWABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  2996. {
  2997.     Coutput << "The expression in a throw statement must denote a variable or value of a reference type "
  2998.                "which is assignable to the type Throwable.";
  2999.  
  3000.     return;
  3001. }
  3002.  
  3003.  
  3004. void SemanticError::PrintBAD_THROWABLE_EXPRESSION_IN_TRY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3005. {
  3006.     Coutput << "The type of the expression in this throw statement, \"";
  3007.     if (NotDot(err.insert1))
  3008.     {
  3009.         Coutput << err.insert1
  3010.                 << '/';
  3011.     }
  3012.     Coutput << err.insert2
  3013.             << "\", is not catchable by the enclosing try statement;";
  3014.     if (wcslen(err.insert3) > 0)
  3015.     {
  3016.         Coutput << " nor is it assignable to an exception in the throws clause of the enclosing method or constructor \""
  3017.                 << err.insert3
  3018.                 << "\";";
  3019.     }
  3020.     Coutput << " nor is it a subclass of RuntimeException or Error.";
  3021.  
  3022.     return;
  3023. }
  3024.  
  3025.  
  3026. void SemanticError::PrintBAD_THROWABLE_EXPRESSION_IN_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3027. {
  3028.     Coutput << "The type of the expression in this throw statement, \"";
  3029.     if (NotDot(err.insert1))
  3030.     {
  3031.         Coutput << err.insert1
  3032.                 << '/';
  3033.     }
  3034.     Coutput << err.insert2
  3035.             << "\", is not assignable to an exception in the throws clause of the enclosing method or constructor \""
  3036.             << err.insert3
  3037.             << "\"; nor is it a subclass of RuntimeException or Error.";
  3038.  
  3039.     return;
  3040. }
  3041.  
  3042.  
  3043. void SemanticError::PrintBAD_THROWABLE_EXPRESSION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3044. {
  3045.     Coutput << "The type of the expression in this throw statement, \"";
  3046.     if (NotDot(err.insert1))
  3047.     {
  3048.         Coutput << err.insert1
  3049.                 << '/';
  3050.     }
  3051.     Coutput << err.insert2
  3052.             << "\", is not a subclass of RuntimeException or Error.";
  3053.  
  3054.     return;
  3055. }
  3056.  
  3057.  
  3058. void SemanticError::PrintMISPLACED_BREAK_STATEMENT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3059. {
  3060.     Coutput << "A \"break\" statement must be enclosed in a \"switch\", \"while\", \"do\" or \"for\" statement.";
  3061.  
  3062.     return;
  3063. }
  3064.  
  3065.  
  3066. void SemanticError::PrintMISPLACED_CONTINUE_STATEMENT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3067. {
  3068.     Coutput << "A \"continue\" statement must be enclosed in a \"while\", \"do\" or \"for\" statement.";
  3069.  
  3070.     return;
  3071. }
  3072.  
  3073.  
  3074. void SemanticError::PrintMISPLACED_EXPLICIT_CONSTRUCTOR_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3075. {
  3076.     Coutput << "Misplaced explicit constructor invocation.";
  3077.  
  3078.     return;
  3079. }
  3080.  
  3081.  
  3082. void SemanticError::PrintINVALID_CONTINUE_TARGET(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3083. {
  3084.     Coutput << "The statement labeled \""
  3085.             << err.insert1
  3086.             << "\" cannot be continued since it is not a \"while\", \"do\" or \"for\" statement.";
  3087.  
  3088.     return;
  3089. }
  3090.  
  3091.  
  3092. void SemanticError::PrintNON_ABSTRACT_TYPE_CONTAINS_ABSTRACT_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3093. {
  3094.     Coutput << "The abstract method \""
  3095.             << err.insert1
  3096.             << "\" is enclosed in a type, \""
  3097.             << err.insert2
  3098.             << "\", that is not abstract.";
  3099.  
  3100.     return;
  3101. }
  3102.  
  3103.  
  3104. void SemanticError::PrintNON_ABSTRACT_TYPE_INHERITS_ABSTRACT_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3105. {
  3106.     Coutput << "The abstract method \""
  3107.             << err.insert1
  3108.             << "\", inherited from type \"";
  3109.     if (NotDot(err.insert2))
  3110.     {
  3111.         Coutput << err.insert2
  3112.                 << '/';
  3113.     }
  3114.     Coutput << err.insert3
  3115.             << "\", is not implemented in the non-abstract class \"";
  3116.     if (NotDot(err.insert4))
  3117.     {
  3118.         Coutput << err.insert4
  3119.                 << '/';
  3120.     }
  3121.     Coutput << err.insert5
  3122.             << "\".";
  3123.  
  3124.     return;
  3125. }
  3126.  
  3127.  
  3128. void SemanticError::PrintNON_ABSTRACT_TYPE_INHERITS_ABSTRACT_METHOD_FROM_ABSTRACT_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3129. {
  3130.     Coutput << "The abstract method \""
  3131.             << err.insert1
  3132.             << "\", inherited from type \"";
  3133.     if (NotDot(err.insert2))
  3134.     {
  3135.         Coutput << err.insert2
  3136.                 << '/';
  3137.     }
  3138.     Coutput << err.insert3
  3139.             << "\", is not implemented in the non-abstract class \"";
  3140.     if (NotDot(err.insert4))
  3141.     {
  3142.         Coutput << err.insert4
  3143.                 << '/';
  3144.     }
  3145.     Coutput << err.insert5
  3146.             << "\". Since the type \"";
  3147.     if (NotDot(err.insert2))
  3148.     {
  3149.         Coutput << err.insert2
  3150.                 << '/';
  3151.     }
  3152.     Coutput << err.insert3
  3153.             << "\" was read from a class file, it is possible that it just needs to be recompiled "
  3154.                "because after having inherited method \""
  3155.             << err.insert1
  3156.             << "\" from an interface, the method was subsequently removed from that interface.";
  3157.  
  3158.     return;
  3159. }
  3160.  
  3161.  
  3162. void SemanticError::PrintNON_ABSTRACT_TYPE_CANNOT_OVERRIDE_DEFAULT_ABSTRACT_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3163. {
  3164.     Coutput << "The abstract method \""
  3165.             << err.insert1
  3166.             << "\", belonging to the class \"";
  3167.     if (NotDot(err.insert2))
  3168.     {
  3169.         Coutput << err.insert2
  3170.                 << '/';
  3171.     }
  3172.     Coutput << err.insert3
  3173.             << "\" has default access."
  3174.                " Therefore, it is not inherited and hence, it cannot be implemented in the non-abstract class \"";
  3175.     if (NotDot(err.insert4))
  3176.     {
  3177.         Coutput << err.insert4
  3178.                 << '/';
  3179.     }
  3180.     Coutput << err.insert5
  3181.             << "\".";
  3182.  
  3183.     return;
  3184. }
  3185.  
  3186.  
  3187. void SemanticError::PrintNO_ABSTRACT_METHOD_IMPLEMENTATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3188. {
  3189.     Coutput << "No implementation of the abstract method \""
  3190.             << err.insert1
  3191.             << "\" declared in type \"";
  3192.     if (NotDot(err.insert2))
  3193.     {
  3194.         Coutput << err.insert2
  3195.                 << '/';
  3196.     }
  3197.     Coutput << err.insert3
  3198.             << "\" was found in class \""
  3199.             << err.insert4
  3200.             << "\".";
  3201.  
  3202.     return;
  3203. }
  3204.  
  3205.  
  3206. void SemanticError::PrintDUPLICATE_INTERFACE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3207. {
  3208.     Coutput << "Duplicate specification of interface \"";
  3209.     if (NotDot(err.insert1))
  3210.     {
  3211.         Coutput << err.insert1
  3212.                 << '/';
  3213.     }
  3214.     Coutput << err.insert2
  3215.             << "\" in definition of type \""
  3216.             << err.insert3
  3217.             << "\".";
  3218.  
  3219.     return;
  3220. }
  3221.  
  3222.  
  3223. void SemanticError::PrintUNKNOWN_QUALIFIED_NAME_BASE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3224. {
  3225.     Coutput << "\""
  3226.             << err.insert1
  3227.             << "\" is either a misplaced package name or a non-existent entity.";
  3228.  
  3229.     return;
  3230. }
  3231.  
  3232.  
  3233. void SemanticError::PrintUNKNOWN_AMBIGUOUS_NAME(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3234. {
  3235.     Coutput << "\""
  3236.             << err.insert1
  3237.             << "\" is either a misplaced package name or a non-existent entity. An expression name is expected in this context.";
  3238.  
  3239.     return;
  3240. }
  3241.  
  3242.  
  3243. void SemanticError::PrintCIRCULAR_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3244. {
  3245.     Coutput << "The class \"";
  3246.     if (NotDot(err.insert1))
  3247.     {
  3248.         Coutput << err.insert1
  3249.                 << "/";
  3250.     }
  3251.     Coutput << err.insert2
  3252.             << "\" is circularly defined with its super type(s).";
  3253.  
  3254.     return;
  3255. }
  3256.  
  3257.  
  3258. void SemanticError::PrintCIRCULAR_INTERFACE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3259. {
  3260.     Coutput << "The interface \"";
  3261.     if (NotDot(err.insert1))
  3262.     {
  3263.         Coutput << err.insert1
  3264.                 << "/";
  3265.     }
  3266.     Coutput << err.insert2
  3267.             << "\" is circularly defined with its super type(s).";
  3268.  
  3269.     return;
  3270. }
  3271.  
  3272.  
  3273. void SemanticError::PrintTYPE_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3274. {
  3275.     Coutput << "The type \"";
  3276.     if (NotDot(err.insert1))
  3277.     {
  3278.         Coutput << err.insert1
  3279.                 << '/';
  3280.     }
  3281.     Coutput << err.insert2
  3282.             << "\" with "
  3283.             << err.insert3
  3284.             << " access is not visible here.";
  3285.  
  3286.     return;
  3287. }
  3288.  
  3289.  
  3290. void SemanticError::PrintPRIVATE_FIELD_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3291. {
  3292.     Coutput << "The field \""
  3293.             << err.insert1
  3294.             << "\" in type \"";
  3295.     if (NotDot(err.insert2))
  3296.     {
  3297.         Coutput << err.insert2
  3298.                 << '/';
  3299.     }
  3300.     Coutput << err.insert3
  3301.             << "\" is private and not accessible here.";
  3302.  
  3303.     return;
  3304. }
  3305.  
  3306.  
  3307. void SemanticError::PrintPROTECTED_FIELD_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3308. {
  3309.     Coutput << "The field \""
  3310.             << err.insert1
  3311.             << "\" in type \"";
  3312.     if (NotDot(err.insert2))
  3313.     {
  3314.         Coutput << err.insert2
  3315.                 << '/';
  3316.     }
  3317.     Coutput << err.insert3
  3318.             << "\" is protected and not accessible here.";
  3319.  
  3320.     return;
  3321. }
  3322.  
  3323.  
  3324. void SemanticError::PrintDEFAULT_FIELD_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3325. {
  3326.     Coutput << "The field \""
  3327.             << err.insert1
  3328.             << "\" in type \"";
  3329.     if (NotDot(err.insert2))
  3330.     {
  3331.         Coutput << err.insert2
  3332.                 << '/';
  3333.     }
  3334.     Coutput << err.insert3
  3335.             << "\" has default access and is not accessible here.";
  3336.  
  3337.     return;
  3338. }
  3339.  
  3340.  
  3341. void SemanticError::PrintPRIVATE_METHOD_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3342. {
  3343.     Coutput << "Method \""
  3344.             << err.insert1
  3345.             << "\" in type \"";
  3346.     if (NotDot(err.insert2))
  3347.     {
  3348.         Coutput << err.insert2
  3349.                 << '/';
  3350.     }
  3351.     Coutput << err.insert3
  3352.             << "\" is private and not accessible here.";
  3353.  
  3354.     return;
  3355. }
  3356.  
  3357.  
  3358. void SemanticError::PrintPROTECTED_METHOD_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3359. {
  3360.     Coutput << "Method \""
  3361.             << err.insert1
  3362.             << "\" in type \"";
  3363.     if (NotDot(err.insert2))
  3364.     {
  3365.         Coutput << err.insert2
  3366.                 << '/';
  3367.     }
  3368.     Coutput << err.insert3
  3369.             << "\" is protected and not accessible here.";
  3370.  
  3371.     return;
  3372. }
  3373.  
  3374.  
  3375. void SemanticError::PrintDEFAULT_METHOD_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3376. {
  3377.     Coutput << "Method \""
  3378.             << err.insert1
  3379.             << "\" in type \"";
  3380.     if (NotDot(err.insert2))
  3381.     {
  3382.         Coutput << err.insert2
  3383.                 << '/';
  3384.     }
  3385.     Coutput << err.insert3
  3386.             << "\" has default access and is not accessible here.";
  3387.  
  3388.     return;
  3389. }
  3390.  
  3391.  
  3392. void SemanticError::PrintPRIVATE_CONSTRUCTOR_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3393. {
  3394.     Coutput << "The constructor \""
  3395.             << err.insert1
  3396.             << "\" in type \"";
  3397.     if (NotDot(err.insert2))
  3398.     {
  3399.         Coutput << err.insert2
  3400.                 << '/';
  3401.     }
  3402.     Coutput << err.insert3
  3403.             << "\" is private. Therefore, it is not accessible here.";
  3404.  
  3405.     return;
  3406. }
  3407.  
  3408.  
  3409. void SemanticError::PrintPROTECTED_CONSTRUCTOR_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3410. {
  3411.     Coutput << "The constructor \""
  3412.             << err.insert1
  3413.             << "\" in type \"";
  3414.     if (NotDot(err.insert2))
  3415.     {
  3416.         Coutput << err.insert2
  3417.                 << '/';
  3418.     }
  3419.     Coutput << err.insert3
  3420.             << "\" is protected. Therefore, it is not accessible here.";
  3421.  
  3422.     return;
  3423. }
  3424.  
  3425.  
  3426. void SemanticError::PrintDEFAULT_CONSTRUCTOR_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3427. {
  3428.     Coutput << "The constructor \""
  3429.             << err.insert1
  3430.             << "\" in type \"";
  3431.     if (NotDot(err.insert2))
  3432.     {
  3433.         Coutput << err.insert2
  3434.                 << '/';
  3435.     }
  3436.     Coutput << err.insert3
  3437.             << "\" has default access. Therefore, it is not accessible here.";
  3438.  
  3439.     return;
  3440. }
  3441.  
  3442.  
  3443. void SemanticError::PrintCONSTRUCTOR_DOES_NOT_THROW_THIS_EXCEPTION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3444. {
  3445.     Coutput << "The constructor invoked here can throw the exception \"";
  3446.     if (NotDot(err.insert1))
  3447.     {
  3448.         Coutput << err.insert1
  3449.                 << "/";
  3450.     }
  3451.     Coutput << err.insert2
  3452.             << "\" which is not thrown by the constructor containing this call.";
  3453.  
  3454.     return;
  3455. }
  3456.  
  3457.  
  3458. void SemanticError::PrintCONSTRUCTOR_DOES_NOT_THROW_SUPER_EXCEPTION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3459. {
  3460.     Coutput << "A constructor associated with this ";
  3461.  
  3462.     if (wcslen(err.insert1) == 0)
  3463.         Coutput << "anonymous type";
  3464.     else
  3465.     {
  3466.         Coutput << "type, \""
  3467.                 << err.insert1
  3468.                 << "\",";
  3469.     }
  3470.  
  3471.     Coutput << " does not throw the exception \"";
  3472.     if (NotDot(err.insert2))
  3473.     {
  3474.         Coutput << err.insert2
  3475.                 << "/";
  3476.     }
  3477.     Coutput << err.insert3
  3478.             << "\" thrown by its super type, \"";
  3479.     if (NotDot(err.insert4))
  3480.     {
  3481.         Coutput << err.insert4
  3482.                 << "/";
  3483.     }
  3484.     Coutput << err.insert5
  3485.             << "\".";
  3486.  
  3487.     return;
  3488. }
  3489.  
  3490.  
  3491. void SemanticError::PrintPARAMETER_REDECLARED(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3492. {
  3493.     Coutput << "The name of a formal parameter, \""
  3494.             << err.insert1
  3495.             << "\", may not be used to declare a local variable or an exception parameter.";
  3496.  
  3497.     return;
  3498. }
  3499.  
  3500.  
  3501. void SemanticError::PrintBAD_ABSTRACT_METHOD_MODIFIER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3502. {
  3503.     Coutput << "A method declaration that contains the keyword \"abstract\" may not also contain one of the keywords: "
  3504.                "\"private\", \"static\", \"final\", \"native\" or \"synchronized\".";
  3505.  
  3506.     return;
  3507. }
  3508.  
  3509.  
  3510. void SemanticError::PrintABSTRACT_METHOD_MODIFIER_CONFLICT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3511. {
  3512.     Coutput << "An abstract method may not also contain the keyword \""
  3513.             << err.insert1
  3514.             << "\".";
  3515.  
  3516.     return;
  3517. }
  3518.  
  3519.  
  3520. void SemanticError::PrintABSTRACT_METHOD_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3521. {
  3522.     Coutput << "An abstract method, \""
  3523.             << err.insert1
  3524.             << "\", cannot be invoked.";
  3525.  
  3526.     return;
  3527. }
  3528.  
  3529.  
  3530. void SemanticError::PrintFINAL_METHOD_OVERRIDE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3531. {
  3532.     Coutput << "The method \""
  3533.             << err.insert1
  3534.             << "\" cannot override the final (or private) method \""
  3535.             << err.insert2
  3536.             << "\" declared in type \"";
  3537.     if (NotDot(err.insert3))
  3538.     {
  3539.         Coutput << err.insert3
  3540.                 << "/";
  3541.     }
  3542.     Coutput << err.insert4
  3543.             << "\".";
  3544.  
  3545.     return;
  3546. }
  3547.  
  3548.  
  3549. void SemanticError::PrintFINAL_METHOD_OVERRIDE_EXTERNALLY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3550. {
  3551.     Coutput << "In class \""
  3552.             << err.insert1
  3553.             << "\", the method \""
  3554.             << err.insert2
  3555.             << "\", inherited from type \"";
  3556.     if (NotDot(err.insert3))
  3557.     {
  3558.         Coutput << err.insert3
  3559.                 << "/";
  3560.     }
  3561.     Coutput << err.insert4
  3562.             << "\", overrides the final (or private) method \""
  3563.             << err.insert5
  3564.             << "\", inherited from type \"";
  3565.     if (NotDot(err.insert6))
  3566.     {
  3567.         Coutput << err.insert6
  3568.                 << "/";
  3569.     }
  3570.     Coutput << err.insert7
  3571.             << "\".";
  3572.  
  3573.     return;
  3574. }
  3575.  
  3576.  
  3577. void SemanticError::PrintPRIVATE_METHOD_OVERRIDE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3578. {
  3579.     Coutput << "The method \""
  3580.             << err.insert1
  3581.             << "\" is overriding the private (should be treated as final) method \""
  3582.             << err.insert2
  3583.             << "\" declared in type \"";
  3584.     if (NotDot(err.insert3))
  3585.     {
  3586.         Coutput << err.insert3
  3587.                 << "/";
  3588.     }
  3589.     Coutput << err.insert4
  3590.             << "\".";
  3591.  
  3592.     return;
  3593. }
  3594.  
  3595.  
  3596. void SemanticError::PrintPRIVATE_METHOD_OVERRIDE_EXTERNALLY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3597. {
  3598.     Coutput << "In class \""
  3599.             << err.insert1
  3600.             << "\", the method \""
  3601.             << err.insert2
  3602.             << "\", inherited from type \"";
  3603.     if (NotDot(err.insert3))
  3604.     {
  3605.         Coutput << err.insert3
  3606.                 << "/";
  3607.     }
  3608.     Coutput << err.insert4
  3609.             << "\", overrides the private (should be treated as final) method \""
  3610.             << err.insert5
  3611.             << "\", inherited from type \"";
  3612.     if (NotDot(err.insert6))
  3613.     {
  3614.         Coutput << err.insert6
  3615.                 << "/";
  3616.     }
  3617.     Coutput << err.insert7
  3618.             << "\".";
  3619.  
  3620.     return;
  3621. }
  3622.  
  3623.  
  3624. void SemanticError::PrintCLASS_METHOD_OVERRIDE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3625. {
  3626.     Coutput << "The instance method \""
  3627.             << err.insert1
  3628.             << "\" cannot override the static method \""
  3629.             << err.insert2
  3630.             << "\" declared in type \"";
  3631.     if (NotDot(err.insert3))
  3632.     {
  3633.         Coutput << err.insert3
  3634.                 << "/";
  3635.     }
  3636.     Coutput << err.insert4
  3637.             << "\".";
  3638.  
  3639.     return;
  3640. }
  3641.  
  3642.  
  3643. void SemanticError::PrintCLASS_METHOD_OVERRIDE_EXTERNALLY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3644. {
  3645.     Coutput << "In class \""
  3646.             << err.insert1
  3647.             << "\", the instance method \""
  3648.             << err.insert2
  3649.             << "\", inherited from type \"";
  3650.     if (NotDot(err.insert3))
  3651.     {
  3652.         Coutput << err.insert3
  3653.                 << "/";
  3654.     }
  3655.     Coutput << err.insert4
  3656.             << "\", cannot override the static method \""
  3657.             << err.insert5
  3658.             << "\", declared in type \"";
  3659.     if (NotDot(err.insert6))
  3660.     {
  3661.         Coutput << err.insert6
  3662.                 << "/";
  3663.     }
  3664.     Coutput << err.insert7
  3665.             << "\".";
  3666.  
  3667.     return;
  3668. }
  3669.  
  3670.  
  3671. void SemanticError::PrintINSTANCE_METHOD_OVERRIDE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3672. {
  3673.     Coutput << "The static method \""
  3674.             << err.insert1
  3675.             << "\" cannot hide the instance method \""
  3676.             << err.insert2
  3677.             << "\" declared in \"";
  3678.     if (NotDot(err.insert3))
  3679.     {
  3680.         Coutput << err.insert3
  3681.                 << "/";
  3682.     }
  3683.     Coutput << err.insert4
  3684.             << "\".";
  3685.  
  3686.     return;
  3687. }
  3688.  
  3689.  
  3690. void SemanticError::PrintINSTANCE_METHOD_OVERRIDE_EXTERNALLY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3691. {
  3692.     Coutput << "In class \""
  3693.             << err.insert1
  3694.             << "\", the static method \""
  3695.             << err.insert2
  3696.             << "\", inherited from type \"";
  3697.     if (NotDot(err.insert3))
  3698.     {
  3699.         Coutput << err.insert3
  3700.                 << "/";
  3701.     }
  3702.     Coutput << err.insert4
  3703.             << "\", hides the instance method \""
  3704.             << err.insert5
  3705.             << "\", declared in type \"";
  3706.     if (NotDot(err.insert6))
  3707.     {
  3708.         Coutput << err.insert6
  3709.                 << "/";
  3710.     }
  3711.     Coutput << err.insert7
  3712.             << "\".";
  3713.  
  3714.     return;
  3715. }
  3716.  
  3717.  
  3718. void SemanticError::PrintBAD_ACCESS_METHOD_OVERRIDE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3719. {
  3720.     Coutput << "The method \""
  3721.             << err.insert1
  3722.             << "\" with "
  3723.             << err.insert2
  3724.             << " access cannot override the method \""
  3725.             << err.insert3
  3726.             << "\" with "
  3727.             << err.insert4
  3728.             << " access declared in type \"";
  3729.     if (NotDot(err.insert5))
  3730.     {
  3731.         Coutput << err.insert5
  3732.                 << "/";
  3733.     }
  3734.     Coutput << err.insert6
  3735.             << "\".";
  3736.  
  3737.     return;
  3738. }
  3739.  
  3740.  
  3741. void SemanticError::PrintBAD_ACCESS_METHOD_OVERRIDE_EXTERNALLY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3742. {
  3743.     Coutput << "In class \""
  3744.             << err.insert1
  3745.             << "\", the method \""
  3746.             << err.insert2
  3747.             << "\" with "
  3748.             << err.insert3
  3749.             << " access inherited from type \"";
  3750.     if (NotDot(err.insert4))
  3751.     {
  3752.         Coutput << err.insert4
  3753.                 << "/";
  3754.     }
  3755.     Coutput << err.insert5
  3756.             << "\", cannot override the method \""
  3757.             << err.insert6
  3758.             << "\" with "
  3759.             << err.insert7
  3760.             << " access inherited from type \"";
  3761.     if (NotDot(err.insert8))
  3762.     {
  3763.         Coutput << err.insert8
  3764.                 << "/";
  3765.     }
  3766.     Coutput << err.insert9
  3767.             << "\".";
  3768.  
  3769.     return;
  3770. }
  3771.  
  3772.  
  3773. void SemanticError::PrintMISMATCHED_OVERRIDDEN_EXCEPTION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3774. {
  3775.     Coutput << "The exception \""
  3776.             << err.insert1
  3777.             << "\" is not the same as or a subclass of any exception in the throws clause of the overridden method \""
  3778.             << err.insert2
  3779.             << "\" declared in type \"";
  3780.     if (NotDot(err.insert3))
  3781.     {
  3782.         Coutput << err.insert3
  3783.                 << "/";
  3784.     }
  3785.     Coutput << err.insert4
  3786.             << "\".";
  3787.  
  3788.     return;
  3789. }
  3790.  
  3791.  
  3792. void SemanticError::PrintMISMATCHED_OVERRIDDEN_EXCEPTION_EXTERNALLY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3793. {
  3794.     Coutput << "In class \""
  3795.             << err.insert1
  3796.             << "\", the exception \""
  3797.             << err.insert2
  3798.             << "\" specified in method \""
  3799.             << err.insert3
  3800.             << "\" inherited from type \"";
  3801.     if (NotDot(err.insert4))
  3802.     {
  3803.         Coutput << err.insert4
  3804.                 << "/";
  3805.     }
  3806.     Coutput << err.insert5
  3807.             << "\", is not the same as or a subclass of any exception in the throws clause of the overridden method \""
  3808.             << err.insert6
  3809.             << "\" declared in type \"";
  3810.     if (NotDot(err.insert7))
  3811.     {
  3812.         Coutput << err.insert7
  3813.                 << "/";
  3814.     }
  3815.     Coutput << err.insert8
  3816.             << "\".";
  3817.  
  3818.     return;
  3819. }
  3820.  
  3821.  
  3822. void SemanticError::PrintABSTRACT_METHOD_WITH_BODY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3823. {
  3824.     Coutput << "The declaration of the abstract or native method, \""
  3825.             << err.insert1
  3826.             << "\", must not contain a method body.";
  3827.  
  3828.     return;
  3829. }
  3830.  
  3831.  
  3832. void SemanticError::PrintNON_ABSTRACT_METHOD_WITHOUT_BODY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3833. {
  3834.     Coutput << "The declaration of the non-abstract and non-native method, \""
  3835.             << err.insert1
  3836.             << "\", must contain a method body.";
  3837.  
  3838.     return;
  3839. }
  3840.  
  3841.  
  3842. void SemanticError::PrintSTATIC_OVERRIDE_ABSTRACT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3843. {
  3844.     Coutput << "The static method \""
  3845.             << err.insert1
  3846.             << "\" cannot hide an abstract method of the same name declared in type \"";
  3847.     if (NotDot(err.insert2))
  3848.     {
  3849.         Coutput << err.insert2
  3850.                 << "/";
  3851.     }
  3852.     Coutput << err.insert3
  3853.             << "\".";
  3854.  
  3855.     return;
  3856. }
  3857.  
  3858.  
  3859. void SemanticError::PrintSTATIC_OVERRIDE_ABSTRACT_EXTERNALLY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3860. {
  3861.     Coutput << "In class \""
  3862.             << err.insert1
  3863.             << "\", the static method \""
  3864.             << err.insert2
  3865.             << "\", inherited from type \"";
  3866.     if (NotDot(err.insert3))
  3867.     {
  3868.         Coutput << err.insert3
  3869.                 << "/";
  3870.     }
  3871.     Coutput << err.insert4
  3872.             << "\", cannot hide the abstract method \""
  3873.             << err.insert5
  3874.             << "\", inherited from type \"";
  3875.     if (NotDot(err.insert6))
  3876.     {
  3877.         Coutput << err.insert6
  3878.                 << "/";
  3879.     }
  3880.     Coutput << err.insert7
  3881.             << "\".";
  3882.  
  3883.     return;
  3884. }
  3885.  
  3886.  
  3887. void SemanticError::PrintCIRCULAR_THIS_CALL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3888. {
  3889.     Coutput << "The constructor \""
  3890.             << err.insert1
  3891.             << "\" may not directly or indirectly invoke itself.";
  3892.  
  3893.     return;
  3894. }
  3895.  
  3896.  
  3897. void SemanticError::PrintINSTANCE_VARIABLE_IN_EXPLICIT_CONSTRUCTOR_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3898. {
  3899.     Coutput << "The instance variable \""
  3900.             << err.insert1
  3901.             << "\" declared in class \""
  3902.             << err.insert2
  3903.             << "\" is not accessible in an explicit constructor invocation.";
  3904.  
  3905.     return;
  3906. }
  3907.  
  3908.  
  3909. void SemanticError::PrintINSTANCE_METHOD_IN_EXPLICIT_CONSTRUCTOR_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3910. {
  3911.     Coutput << "The instance method \""
  3912.             << err.insert1
  3913.             << "\" declared in this class, \""
  3914.             << err.insert2
  3915.             << "\", or one of its super classes, is not accessible in an explicit constructor invocation.";
  3916.  
  3917.     return;
  3918. }
  3919.  
  3920.  
  3921. void SemanticError::PrintSYNTHETIC_VARIABLE_ACCESS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3922. {
  3923.     Coutput << "Illegal attempt to access the synthetic field \""
  3924.             << err.insert1
  3925.             << "\" contained in class \"";
  3926.     if (NotDot(err.insert2))
  3927.     {
  3928.         Coutput << err.insert2
  3929.                 << "/";
  3930.     }
  3931.     Coutput << err.insert3
  3932.             << "\".";
  3933.  
  3934.     return;
  3935. }
  3936.  
  3937.  
  3938. void SemanticError::PrintSYNTHETIC_METHOD_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3939. {
  3940.     Coutput << "Illegal attempt to invoke the synthetic method \""
  3941.             << err.insert1
  3942.             << "\" contained in class \"";
  3943.     if (NotDot(err.insert2))
  3944.     {
  3945.         Coutput << err.insert2
  3946.                 << "/";
  3947.     }
  3948.     Coutput << err.insert3
  3949.             << "\".";
  3950.  
  3951.     return;
  3952. }
  3953.  
  3954.  
  3955. void SemanticError::PrintSYNTHETIC_CONSTRUCTOR_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3956. {
  3957.     Coutput << "Illegal attempt to invoke the synthetic constructor \""
  3958.             << err.insert1
  3959.             << "\" from class \"";
  3960.     if (NotDot(err.insert2))
  3961.     {
  3962.         Coutput << err.insert2
  3963.                 << "/";
  3964.     }
  3965.     Coutput << err.insert3
  3966.             << "\".";
  3967.  
  3968.     return;
  3969. }
  3970.  
  3971.  
  3972. void SemanticError::PrintTHIS_IN_EXPLICIT_CONSTRUCTOR_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3973. {
  3974.     Coutput << "The expression \""
  3975.             << err.insert1
  3976.             << "\" may not be used in an explicit constructor invocation.";
  3977.  
  3978.     return;
  3979. }
  3980.  
  3981.  
  3982. void SemanticError::PrintSUPER_IN_EXPLICIT_CONSTRUCTOR_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3983. {
  3984.     Coutput << "The expression \""
  3985.             << err.insert1
  3986.             << "\" may not be used in an explicit constructor invocation.";
  3987.  
  3988.     return;
  3989. }
  3990.  
  3991.  
  3992. void SemanticError::PrintINNER_CONSTRUCTOR_IN_EXPLICIT_CONSTRUCTOR_INVOCATION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  3993. {
  3994.     Coutput << "The constructor for class \"";
  3995.     if (NotDot(err.insert1))
  3996.     {
  3997.         Coutput << err.insert1
  3998.                 << "/";
  3999.     }
  4000.     Coutput << err.insert2
  4001.             << "\" is not accessible from an explicit constructor invocation in the immediately enclosing class \"";
  4002.     if (NotDot(err.insert3))
  4003.     {
  4004.         Coutput << err.insert3
  4005.                 << "/";
  4006.     }
  4007.     Coutput << err.insert4
  4008.             << "\".";
  4009.  
  4010.     return;
  4011. }
  4012.  
  4013.  
  4014. void SemanticError::PrintEXPRESSION_NOT_CONSTANT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4015. {
  4016.     Coutput << "A constant expression is expected in this context.";
  4017.  
  4018.     return;
  4019. }
  4020.  
  4021.  
  4022. void SemanticError::PrintUNCATCHABLE_METHOD_THROWN_CHECKED_EXCEPTION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4023. {
  4024.     Coutput << "The method \""
  4025.             << err.insert1
  4026.             << "\" can throw the checked exception \"";
  4027.     if (NotDot(err.insert2))
  4028.     {
  4029.         Coutput << err.insert2
  4030.                 << "/";
  4031.     }
  4032.     Coutput << err.insert3
  4033.             << "\", but its invocation is neither enclosed in a try statement that can catch "
  4034.                "that exception nor in the body of a method or constructor that \"throws\" that exception.";
  4035.  
  4036.     return;
  4037. }
  4038.  
  4039.  
  4040. void SemanticError::PrintUNCATCHABLE_CONSTRUCTOR_THROWN_CHECKED_EXCEPTION(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4041. {
  4042.     Coutput << "The constructor \""
  4043.             << err.insert1
  4044.             << "\" can throw the checked exception \"";
  4045.     if (NotDot(err.insert2))
  4046.     {
  4047.         Coutput << err.insert2
  4048.                 << "/";
  4049.     }
  4050.     Coutput << err.insert3
  4051.             << "\", but its invocation is neither enclosed in a try statement that can catch "
  4052.                "that exception nor in the body of a method or constructor that \"throws\" that exception.";
  4053.  
  4054.     return;
  4055. }
  4056.  
  4057.  
  4058. void SemanticError::PrintUNREACHABLE_CATCH_CLAUSE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4059. {
  4060.     Coutput << "This catch block may be unreachable because there is no exception "
  4061.                "whose type is assignable to \"";
  4062.     if (NotDot(err.insert1))
  4063.     {
  4064.         Coutput << err.insert1
  4065.                 << "/";
  4066.     }
  4067.     Coutput << err.insert2
  4068.             << "\" that can be thrown during execution of the body of the try block.";
  4069.  
  4070.     return;
  4071. }
  4072.  
  4073.  
  4074. void SemanticError::PrintUNREACHABLE_STATEMENT(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4075. {
  4076.     Coutput << "This statement is unreachable.";
  4077.  
  4078.     return;
  4079. }
  4080.  
  4081.  
  4082. void SemanticError::PrintUNREACHABLE_STATEMENTS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4083. {
  4084.     Coutput << "These statements are unreachable.";
  4085.  
  4086.     return;
  4087. }
  4088.  
  4089.  
  4090. void SemanticError::PrintUNREACHABLE_CONSTRUCTOR_BODY(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4091. {
  4092.     Coutput << "The body of this constructor is unreachable because the last initializer block "
  4093.                "in this class does not complete normally.";
  4094.  
  4095.     return;
  4096. }
  4097.  
  4098.  
  4099. void SemanticError::PrintBLOCKED_CATCH_CLAUSE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4100. {
  4101.     Coutput << "This catch block is unreachable: the exception \"";
  4102.     if (NotDot(err.insert1))
  4103.     {
  4104.         Coutput << err.insert1
  4105.                 << "/";
  4106.     }
  4107.     Coutput << err.insert2
  4108.             << "\" was used in a previous catch clause in this try statement at location "
  4109.             << err.insert3
  4110.             << '.';
  4111.  
  4112.     return;
  4113. }
  4114.  
  4115.  
  4116. void SemanticError::PrintVARIABLE_NOT_DEFINITELY_ASSIGNED(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4117. {
  4118.     Coutput << "The variable \""
  4119.             << err.insert1
  4120.             << "\" may be accessed here before having been definitely assigned a value.";
  4121.  
  4122.     return;
  4123. }
  4124.  
  4125.  
  4126. void SemanticError::PrintTYPED_METHOD_WITH_NO_RETURN(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4127. {
  4128.     Coutput << "The method \""
  4129.             << err.insert1
  4130.             << "\" must contain a return statement with an expression compatible with type \""
  4131.             << err.insert2
  4132.             << "\".";
  4133.  
  4134.     return;
  4135. }
  4136.  
  4137.  
  4138. void SemanticError::PrintDEFAULT_METHOD_NOT_OVERRIDDEN(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4139. {
  4140.     Coutput << "Method \""
  4141.             << err.insert1
  4142.             << "\" in class \"";
  4143.     if (NotDot(err.insert2))
  4144.     {
  4145.         Coutput << err.insert2
  4146.                 << "/";
  4147.     }
  4148.     Coutput << err.insert3
  4149.             << "\" does not override the corresponding method with default access in class \"";
  4150.     if (NotDot(err.insert4))
  4151.     {
  4152.         Coutput << err.insert4
  4153.                 << "/";
  4154.     }
  4155.     Coutput << err.insert5
  4156.             << "\".";
  4157.  
  4158.     return;
  4159. }
  4160.  
  4161.  
  4162. void SemanticError::PrintTYPE_NOT_IN_UNNAMED_PACKAGE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4163. {
  4164.     Coutput << "The file \""
  4165.             << err.insert1
  4166.             << ".class\" was found in directory \""
  4167.             << err.insert2
  4168.             << "\" specified in the CLASSPATH. However, that class file specifies a type associated with the named package \""
  4169.             << err.insert3
  4170.             << "\" instead of the unnamed package.";
  4171. }
  4172.  
  4173.  
  4174. void SemanticError::PrintTYPE_IN_WRONG_PACKAGE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4175. {
  4176.     Coutput << "The type \""
  4177.             << err.insert1
  4178.             << "\" was found in package \""
  4179.             << err.insert2
  4180.             << "\". However, that type is associated with ";
  4181.     if (wcslen(err.insert3) == 0)
  4182.         Coutput << "the unnamed package";
  4183.     else
  4184.     {
  4185.         Coutput << "another named package, \""
  4186.                 << err.insert3
  4187.                 << "\"";
  4188.     }
  4189.     Coutput << '.';
  4190.  
  4191.     return;
  4192. }
  4193.  
  4194.  
  4195. void SemanticError::PrintTYPE_NAME_MISMATCH(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4196. {
  4197.     Coutput << "The name of the type specified, \"";
  4198.     if (NotDot(err.insert1))
  4199.     {
  4200.         Coutput << err.insert1
  4201.                 << "/";
  4202.     }
  4203.     Coutput << err.insert2
  4204.             << "\", does not match the name found in the class file: \""
  4205.             << err.insert3
  4206.             << "\".";
  4207.  
  4208.     return;
  4209. }
  4210.  
  4211.  
  4212. void SemanticError::PrintDEPRECATED_TYPE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4213. {
  4214.     Coutput << "The type \"";
  4215.     if (NotDot(err.insert1))
  4216.     {
  4217.         Coutput << err.insert1
  4218.                 << "/";
  4219.     }
  4220.     Coutput << err.insert2
  4221.             << "\" has been deprecated.";
  4222.  
  4223.     return;
  4224. }
  4225.  
  4226.  
  4227. void SemanticError::PrintDEPRECATED_FIELD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4228. {
  4229.     Coutput << "The variable \""
  4230.             << err.insert1
  4231.             << "\" declared in type \"";
  4232.     if (NotDot(err.insert2))
  4233.     {
  4234.         Coutput << err.insert2
  4235.                 << "/";
  4236.     }
  4237.     Coutput << err.insert3
  4238.             << "\" has been deprecated.";
  4239.  
  4240.     return;
  4241. }
  4242.  
  4243.  
  4244. void SemanticError::PrintDEPRECATED_METHOD(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4245. {
  4246.     Coutput << "The method \""
  4247.             << err.insert1
  4248.             << "\" declared in type \"";
  4249.     if (NotDot(err.insert2))
  4250.     {
  4251.         Coutput << err.insert2
  4252.                 << "/";
  4253.     }
  4254.     Coutput << err.insert3
  4255.             << "\" has been deprecated.";
  4256.  
  4257.     return;
  4258. }
  4259.  
  4260.  
  4261. void SemanticError::PrintDEPRECATED_CONSTRUCTOR(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4262. {
  4263.     Coutput << "The constructor \""
  4264.             << err.insert1
  4265.             << "\" declared in type \"";
  4266.     if (NotDot(err.insert2))
  4267.     {
  4268.         Coutput << err.insert2
  4269.                 << "/";
  4270.     }
  4271.     Coutput << err.insert3
  4272.             << "\" has been deprecated.";
  4273.  
  4274.     return;
  4275. }
  4276.  
  4277.  
  4278. void SemanticError::PrintONE_UNNAMED_PACKAGE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4279. {
  4280.     Coutput << "The type \""
  4281.             << err.insert1
  4282.             << "\" was found in directory \""
  4283.             << err.insert2
  4284.             << "\" specified in the CLASSPATH. It is accessible here only because, by default, this compiler uses "
  4285.                "one unnamed package. In a compiler that associates an unnamed package with each directory "
  4286.                "(as this compiler does with the +P option) this access would be illegal.";
  4287.  
  4288.     return;
  4289. }
  4290.  
  4291.  
  4292.  
  4293. void SemanticError::PrintCOMPRESSED_ZIP_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4294. {
  4295.     Coutput << "The file "
  4296.             << err.insert1
  4297.             << "("
  4298.             << err.insert2
  4299.             << "/"
  4300.             << err.insert3
  4301.             << ") is in an unsupported compressed format. (Unzip and) Rezip \""
  4302.             << err.insert1
  4303.             << "\".";
  4304.  
  4305.     return;
  4306. }
  4307.  
  4308.  
  4309. void SemanticError::PrintINVALID_CLASS_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4310. {
  4311.     Coutput << "The class file \"";
  4312.     if (NotDot(err.insert1))
  4313.     {
  4314.         Coutput << err.insert1
  4315.                 << "/";
  4316.     }
  4317.     Coutput << err.insert2
  4318.             << ".class\" has an invalid format.";
  4319.  
  4320.     return;
  4321. }
  4322.  
  4323.  
  4324. void SemanticError::PrintCANNOT_OPEN_CLASS_FILE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4325. {
  4326.     Coutput << "Unable to open file associated with type \"";
  4327.     if (NotDot(err.insert1))
  4328.     {
  4329.         Coutput << err.insert1
  4330.                 << "/";
  4331.     }
  4332.     Coutput << err.insert2
  4333.             << "\".";
  4334.  
  4335.     return;
  4336. }
  4337.  
  4338.  
  4339. void SemanticError::PrintONE_ONE_FEATURE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4340. {
  4341.     Coutput << "This is a 1.1 feature.";
  4342.  
  4343.     return;
  4344. }
  4345.  
  4346.  
  4347. void SemanticError::PrintSTATIC_NOT_INNER_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4348. {
  4349.     Coutput << "The static class \"";
  4350.     if (NotDot(err.insert1))
  4351.     {
  4352.         Coutput << err.insert1
  4353.                 << "/";
  4354.     }
  4355.     Coutput << err.insert2
  4356.             << "\" is not an inner class.";
  4357.  
  4358.     return;
  4359. }
  4360.  
  4361.  
  4362. void SemanticError::PrintTYPE_NOT_INNER_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4363. {
  4364.     Coutput << "The type \"";
  4365.     if (NotDot(err.insert1))
  4366.     {
  4367.         Coutput << err.insert1
  4368.                 << "/";
  4369.     }
  4370.     Coutput << err.insert2
  4371.             << "\", is not an inner class that is immediately enclosed in type \"";
  4372.     if (NotDot(err.insert3))
  4373.     {
  4374.         Coutput << err.insert3
  4375.                 << "/";
  4376.     }
  4377.     Coutput << err.insert4
  4378.             << "\".";
  4379.  
  4380.     return;
  4381. }
  4382.  
  4383.  
  4384. void SemanticError::PrintSUPER_TYPE_NOT_INNER_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4385. {
  4386.     Coutput << "The super type \"";
  4387.     if (NotDot(err.insert1))
  4388.     {
  4389.         Coutput << err.insert1
  4390.                 << "/";
  4391.     }
  4392.     Coutput << err.insert2
  4393.             << "\" of this type, \"";
  4394.     if (NotDot(err.insert3))
  4395.     {
  4396.         Coutput << err.insert3
  4397.                 << "/";
  4398.     }
  4399.     Coutput << err.insert4
  4400.             << "\", is not an inner class that is immediately enclosed in type \"";
  4401.     if (NotDot(err.insert5))
  4402.     {
  4403.         Coutput << err.insert5
  4404.                 << "/";
  4405.     }
  4406.     Coutput << err.insert6
  4407.             << "\".";
  4408.  
  4409.     return;
  4410. }
  4411.  
  4412.  
  4413. void SemanticError::PrintSTATIC_FIELD_IN_INNER_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4414. {
  4415.     Coutput << "An inner class may not contain a static field that is not final.";
  4416.  
  4417.     return;
  4418. }
  4419.  
  4420.  
  4421. void SemanticError::PrintSTATIC_METHOD_IN_INNER_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4422. {
  4423.     Coutput << "Inner class may not contain static method.";
  4424.  
  4425.     return;
  4426. }
  4427.  
  4428.  
  4429. void SemanticError::PrintSTATIC_TYPE_IN_INNER_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4430. {
  4431.     Coutput << "The static type \""
  4432.             << err.insert1
  4433.             << "\" is enclosed in an inner class, \""
  4434.             << err.insert2
  4435.             << "\", located at "
  4436.             << err.insert3
  4437.             << '.';
  4438.  
  4439.     return;
  4440. }
  4441.  
  4442.  
  4443. void SemanticError::PrintSTATIC_INITIALIZER_IN_INNER_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4444. {
  4445.     Coutput << "This static initializer is enclosed in an inner class, \""
  4446.             << err.insert1
  4447.             << "\", located at "
  4448.             << err.insert2
  4449.             << '.';
  4450.  
  4451.     return;
  4452. }
  4453.  
  4454.  
  4455.  
  4456. void SemanticError::PrintINNER_CLASS_REFERENCE_TO_NON_FINAL_LOCAL_VARIABLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4457. {
  4458.     Coutput << "Invalid reference in inner class \"";
  4459.     if (NotDot(err.insert1))
  4460.     {
  4461.         Coutput << err.insert1
  4462.                 << "/";
  4463.     }
  4464.     Coutput << err.insert2
  4465.             << "\" to a non-final local variable, \""
  4466.             << err.insert3
  4467.             << "\", declared in method \""
  4468.             << err.insert4
  4469.             << "\".";
  4470.  
  4471.     return;
  4472. }
  4473.  
  4474.  
  4475. void SemanticError::PrintSTATIC_PROTECTED_FIELD_ACCESS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4476. {
  4477.     Coutput << "The field \""
  4478.             << err.insert1
  4479.             << "\" in type \"";
  4480.     if (NotDot(err.insert2))
  4481.     {
  4482.         Coutput << err.insert2
  4483.                 << '/';
  4484.     }
  4485.     Coutput << err.insert3
  4486.             << "\" is a protected field contained in a different package than this one. "
  4487.                "Therefore, even though it may be accessible here as a simple name (if it is not hidden), "
  4488.                "it is not accessible via a field access.";
  4489.  
  4490.     return;
  4491. }
  4492.  
  4493.  
  4494. void SemanticError::PrintSTATIC_PROTECTED_METHOD_ACCESS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4495. {
  4496.     Coutput << "The method \""
  4497.             << err.insert1
  4498.             << "\" in type \"";
  4499.     if (NotDot(err.insert2))
  4500.     {
  4501.         Coutput << err.insert2
  4502.                 << '/';
  4503.     }
  4504.     Coutput << err.insert3
  4505.             << "\" is a protected method contained in a different package than this one. "
  4506.                "Therefore, even though it may be accessible here as a simple name (if it is not hidden), "
  4507.                "it is not accessible via a field access.";
  4508.  
  4509.     return;
  4510. }
  4511.  
  4512.  
  4513. void SemanticError::PrintINHERITANCE_AND_LEXICAL_SCOPING_CONFLICT_WITH_LOCAL(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4514. {
  4515.     Coutput << "Ambiguous reference to field \""
  4516.             << err.insert1
  4517.             << "\" declared in (or inherited from) type \"";
  4518.     if (NotDot(err.insert2))
  4519.     {
  4520.         Coutput << err.insert2
  4521.                 << "/";
  4522.     }
  4523.     Coutput << err.insert3
  4524.             << "\" but also declared in the enclosing method \""
  4525.             << err.insert4
  4526.             << "\". Explicit qualification is required.";
  4527.  
  4528.     return;
  4529. }
  4530.  
  4531. void SemanticError::PrintINHERITANCE_AND_LEXICAL_SCOPING_CONFLICT_WITH_MEMBER(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4532. {
  4533.     Coutput << "Ambiguous reference to member named \""
  4534.             << err.insert1
  4535.             << "\" inherited from type \"";
  4536.     if (NotDot(err.insert2))
  4537.     {
  4538.         Coutput << err.insert2
  4539.                 << "/";
  4540.     }
  4541.     Coutput << err.insert3
  4542.             << "\" but also declared or inherited in the enclosing type \"";
  4543.     if (NotDot(err.insert4))
  4544.     {
  4545.         Coutput << err.insert4
  4546.                 << "/";
  4547.     }
  4548.     Coutput << err.insert5
  4549.             << "\". Explicit qualification is required.";
  4550.  
  4551.     return;
  4552. }
  4553.  
  4554.  
  4555. void SemanticError::PrintILLEGAL_THIS_FIELD_ACCESS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4556. {
  4557.     Coutput << "The type \"";
  4558.     if (NotDot(err.insert1))
  4559.     {
  4560.         Coutput << err.insert1
  4561.                 << "/";
  4562.     }
  4563.     Coutput << err.insert2
  4564.             << "\" is either not an outer type of type \"";
  4565.     if (NotDot(err.insert3))
  4566.     {
  4567.         Coutput << err.insert3
  4568.                 << "/";
  4569.     }
  4570.     Coutput << err.insert4
  4571.             << "\" or it is not accessible because this expression appears in a static region.";
  4572.  
  4573.     return;
  4574. }
  4575.  
  4576.  
  4577. void SemanticError::PrintENCLOSING_INSTANCE_NOT_ACCESSIBLE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4578. {
  4579.     Coutput << "An instance of \"";
  4580.     if (NotDot(err.insert1))
  4581.     {
  4582.         Coutput << err.insert1
  4583.                 << "/";
  4584.     }
  4585.     Coutput << err.insert2
  4586.             << StringConstant::US__DO
  4587.             << StringConstant::US_this
  4588.             << "\" is not accessible here"
  4589.             << ". In general, an enclosing instance is accessible only in the body of an instance method, "
  4590.                "constructor (after the explicit constructor invocation, if any), "
  4591.                "initializer block, or in the initializer expression of an instance variable.";
  4592.  
  4593.     return;
  4594. }
  4595.  
  4596.  
  4597. void SemanticError::PrintZERO_DIVIDE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4598. {
  4599.     Coutput << "Attempt to divide by zero.";
  4600.  
  4601.     return;
  4602. }
  4603.  
  4604.  
  4605. void SemanticError::PrintVOID_TO_STRING(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4606. {
  4607.     Coutput << "Attempt to convert an expression of type void into a String.";
  4608.  
  4609.     return;
  4610. }
  4611.  
  4612.  
  4613. void SemanticError::PrintINVALID_ENCLOSING_INSTANCE(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4614. {
  4615.     Coutput << "The super type of this type, \"";
  4616.     if (NotDot(err.insert1))
  4617.     {
  4618.         Coutput << err.insert1
  4619.                 << "/";
  4620.     }
  4621.     Coutput << err.insert2
  4622.             << "\", is immediately enclosed in type \"";
  4623.     if (NotDot(err.insert3))
  4624.     {
  4625.         Coutput << err.insert3
  4626.                 << "/";
  4627.     }
  4628.     Coutput << err.insert4
  4629.             << "\" which does not match the type of this primary expression, \"";
  4630.     if (NotDot(err.insert5))
  4631.     {
  4632.         Coutput << err.insert5
  4633.                 << "/";
  4634.     }
  4635.     Coutput << err.insert6
  4636.             << "\".";
  4637.  
  4638.     return;
  4639. }
  4640.  
  4641.  
  4642. void SemanticError::PrintCONSTRUCTOR_FOUND_IN_ANONYMOUS_CLASS(ErrorInfo &err, LexStream *lex_stream, Control &control)
  4643. {
  4644.     Coutput << "An anonymous class cannot have a constructor.";
  4645.  
  4646.     return;
  4647. }
  4648.